ubuntu部署mysql
更新服务源码
sudo apt update
sudo apt upgrade

安装mysql
sudo apt install mysql-server -y

查看mysql的状态
systemctl status mysql

登录mysql,因为没有密码,所以可以直接登录
mysql -u root

查看当前mysql的信息
select @@hostname,@@port,@@version,@@basedir,@@datadir,user(),database();

查看当前mysql的用户信息
select host,user,plugin from mysql.user;

设置root用户可以被外网访问
rename user root@localhost to root;

给root用户设置密码
alter user 'root'@'%' identified with mysql_native_password by '新密码';
修改配置文件
vim /etc/mysql/mysql.conf.d/mysqld.cnf
将 bind-address=127.0.0.1 改成 bind-address=0.0.0.0

重启mysql
systemctl restart mysql
navicat连接mysql


浙公网安备 33010602011771号