【CentOS安装Mysql】
yum list installed mysql*
yum list mysql*
yum install mysql-server
service mysqld start
service mysqld stop
vi /etc/my.cnf
systemctl start mysqld
systemctl stop mysqld
systemctl status mysqld
【Ubunt安装Mysql】
sudo apt-get install mysql-server
查看mysql8是否安装成功
mysql -V 查看版本
sudo service mysql stop 关闭Mysql
sudo service mysql start 启动mysql服务
--------------------------------------------------------
# grep "password" /var/log/mysql/mysqld.log
2023-07-31T04:35:28.811740Z 6 [Warning] [MY-010453] [Server] root@localhost is created with an empty password ! Please consider switching off the --initialize-insecure option.
安装后MySQL的error log提示:[Warning] root@localhost is created with an empty password ! Please consider switching off the --initialize-insecure option.
解决:
# sudo mysql -uroot
mysql> alter user 'root'@'localhost' identified with mysql_native_password by 'xxx';
mysql> FLUSH PRIVILEGES;
登录
# mysql -u root -pxxx
mysql> use mysql
mysql> select User,authentication_string,Host from user;
mysql> update user set host='%' where user='root';
解决Can't connect to MYSQL server on "ip address"(10061)
一、现象
在Window10上远程连接MySQL数据库时报错如下:
Can't connect to MYSQL server on "ip address"(10061)
二、产生原因
- 数据库服务器没有对外开放mysql的默认端口3306
- 未设置远程用户访问权限
三、解决方法
1.解决端口问题
(1)检查下数据库服务器的3306端口是否开放
数据库服务器上打开终端查看3306端口是否打开:
$ netstat -an|grep 3306
tcp6 0 0 127.0.0.1:3306 0.0.0.0:* LISTEN
如果是上图所示结果:127.0.0.1:3306,说明端口是没有对外开放的。
(2)开放端口
修改mysql配置文件:
$ sudo vim /etc/mysql/mysql.conf.d/mysqld.cnf
修改该文件,注释掉
#bind-address =127.0.0.1
修改完之后重启