ubuntu安装mysql

配置mysql

1、安装Mysql

sudo apt-get install mysql-server

sudo apt-get install mysql-client

sudo apt-get install libmysqlclient-dev

sudo vim /etc/mysql/debian.cnf进去以后用里面的用户名和密码进行登陆

mysql -u用户名 -p密码

use mysql

update user set plugin='mysql_native_password' where user='root';

update user set authentication_string=password('123') where user='root';

flush privileges;

提示密码强度太低

mysql -u root -p  #登录

mysql>set global validate_password_policy=0; #密码强度设为最低等级

mysql>set global validate_password_length=4; #密码允许最小长度为4

mysql>flush privileges;                      #更新授权表,生效

修改密码

mysql>use mysql;

mysql>update user set authentication_string=password('新密码') where user='root';

mysql> flush privileges;

mysql> quit;

增加普通用户

lzy@lzy-ZHAOYANG-E52-80:~$  sudo mysql -uroot -pxxxxxx

mysql> create user 'embsky'@'%' identified by 'Lzy@112233';

Query OK, 0 rows affected (0.00 sec)

mysql> grant all privileges on *.* to 'embsky'@'%';

Query OK, 0 rows affected (0.00 sec)

mysql> flush privileges;

Query OK, 0 rows affected (0.00 sec)

mysql> exit

如果创建的普通用户还是进不去,更新一下密码

update user set authentication_string=password('新密码') where user='普通用户';

flush privileges;

quit;

你可能感兴趣的:(ubuntu安装mysql)