Ubunton安装mysql

时间:2023-03-10 07:04:38
Ubunton安装mysql

#手下下载tar.gz包
#首先手工建立mysql用户和用户组
 > groupadd mysql
 > useradd -r -g mysql mysql
#然后就是安装的解压 编译安装
 > tar zxvf mysql-5.6.10.tar.gz
 > cd mysql-5.6.10
 > cmake .
 > make -j 2
 > make install

#然后就是一些权限的配置 服务的启动
 > cd /usr/local/mysql
 > chown -R mysql .
 > chgrp -R mysql .
 > scripts/mysql_install_db --user=mysql
 > chown -R root .
 > chown -R mysql data
#将mysql配置文件拷贝到etc目录(全局配置)
 > cp support-files/my-default.cnf /etc/my.cnf
#启动mysql
 > bin/mysqld_safe --user=mysql &
# 复制mysql.server脚本到/etc/init.d(初始化服务)
 > cp support-files/mysql.server /etc/init.d/mysql.server

#启动mysql

> bin/mysqld_safe --user=mysql &

#初始化mysql root用户密码

> bin/mysqladmin -u root password '密码文字'

#查看mysql运行状态

sudo service mysql.server status

#如果显示 not running,应该是前面没有启动服务,可直接用service mysql.server start启动

sudo service mysql.server [status|start|stop]

#让mysql开机启动[defaults],取消开机启动[remove]

sudo update-rc.d -f mysql.server defaults [remove]

#将mysql/bin/mysql命令加入到用户命令中,或将mysql/bin目录加入path

加入用户命令:

sudo ln -s /usr/local/mysql/bin/mysql /usr/local/bin/mysql

加入环境变量:

export PATH=$PATH:/usr/local/mysql/bin

#允许root用户远程登录

1>进入mysql: mysql –u root –p

2>改变数据库: use mysql;

3>从任意主机登录: grant all privileges on *.* to root@"%" identified by "密码文字" with grant option;

4>从指定主机登录: grant all privileges on *.* to root@"192.168.1.101" identified by "passw0rd" with grant option;

5>授权生效: flush privileges;

6>查看host为%授权是否添加: select * from user;

> mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 11
Server version: 5.6.15 Source distribution

Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql>

熟悉的窗口啊