Ubuntu 18.04.6 安装配置mysql
查看系统版本
uname -a
cat /etc/issue
联网安装mysql 软件
#查看安装软件中是否包含mysql
dpkg -l | grep mysql
# 安装msyql (open (13: 权限不够)
# apt install mysql-server -y
sudo apt install mysql-server -y
#查看mysql 安装状态
systemctl status mysql
# 查看mysql监听端口
netstat -ntlp | grep mysql
mysql 启动以后面临的两个问题
- 数据库的登录:密码登录,数据库的远程登录
- 数据库字符集的处理,默认采用utf-8
如果不是root用户的情况下要用sudo ,也可以切换到root用户
无密码登录
sudo mysql -uroot
设置登录密码和远程登录
mysql客户端配置
#查看mysql 用户
select host,user,plugin,authentication_string from user;
#设置root 用户本地登录密码
update user set plugin='mysql_native_password',authentication_string=password('root') where user='root';
# 授权mysql 远程登录
grant all on *.* to root@'%' identified by 'root' with grant option;
# 刷新权限就向事务一样
flush privileges;
mysql配置文件设置
vim /etc/mysql/mysql.conf.d/mysqld.cnf
# 将43行127.0.0.1改成0.0.0.0
bind-address = 0.0.0.0
设置mysql数据库的编码
vim /etc/mysql/mysql.conf.d/mysqld.cnf
# 31行添加
character_set_server=utf8