文章目录
Linux安装mysql
环境
- ubuntu18
安装mysql
卸载
sudo apt-get --purge remove mysql-server mysql-common mysql-client
安装
sudo apt-get install mysql-server mysql-common mysql-client
启动
/etc/init.d/mysql restart
设置字符编码为utf-8
sudo vim /etc/mysql/my.cnf
添加如下内容
[mysqld]
collation-server = utf8_unicode_ci
init-connect='SET NAMES utf8'
character-set-server = utf8
新建root账户
删除root账户
DROP USER 'root'@'localhost';
新建root账户
CREATE USER 'root'@'%' IDENTIFIED BY '123456';
授权
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' WITH GRANT OPTION;
刷新系统权限表
FLUSH PRIVILEGES;
开启远程授权
切换库
use mysql;
查看权限
select host from user where user='root';
授权
update user set host = '%' where user ='root';
修改配置文件
- 解除ip绑定
[外链图片转存失败(img-zNERvaea-1564830571767)(https://upload-images.jianshu.io/upload_images/3405165-98cf24147369244a.png?imageMogr2/auto-orient/strip|imageView2/2/w/1240)]
测试
开启、关闭、重启mysql服务命令
开启
service mysql start
关闭
service mysql stop
重启
service mysql restart