ubuntu-16.04.1-server安裝mysql

MySQL

1.安裝MySQL
apt-get update
apt-get install mysql-server
2.配置MySQL

vi /etc/mysql/my.cnf
/** 也可能是/etc/mysql/mysql.conf.d/mysqld.cnf,裡面要包含[mysqld]的配置**/
在[mysqld] 添加以下項
character_set_server=utf8
skip-name-resolve
skip-external-locking
重啟服務:
service mysql restart
3.配置MySQL權限(重要)
(1)打開配置文件(my.cnf),找到這行
bind-address = 127.0.0.1
將這行註釋掉,並在[mysqld] 加上(上面已經有這個配置瞭)
skip-name-resolve
然後重啟服務。
mysql -uroot -p

(2)配置用戶

grant usage on *.* to 'username'@'hostname' identified by 'passwd' with grant option; //添加用戶

grant all privileges on *.* to 'username'@'hostname' identified by 'passwd'; //添加權限

flush privileges; //更新權限

grant usage on *.* to 'sdgsgssql'@'%' identified by 'lgsgdsgi' with grant option;

grant all privileges on *.* to 'lsgsdgql'@'%' identified by 'ldgsdgg';

發佈留言