1.最新mysql5.7.24版本下载地址https://dev.mysql.com/downloads/mysql/
2.将安装包放置 /usr/local/mysql,mysql文件夹自己创建
3.安装
解压tar包 tar -xvf mysql-5.7.24-1.el7.x86_64.rpm-bundle.tar
依次执行
[root@centos-linux ~]# rpm -ivh mysql-community-common-5.7.24-1.el7.x86_64.rpm
[root@centos-linux ~]# rpm -ivh mysql-community-libs-5.7.24-1.el7.x86_64.rpm
[root@centos-linux ~]# rpm -ivh mysql-community-client-5.7.24-1.el7.x86_64.rpm
[root@centos-linux ~]# rpm -ivh mysql-community-server-5.7.24-1.el7.x86_64.rpm
安装过程中有报错需要安装libaio包和net-tools包:可以yum安装一下,缺少的perl和libaio软件包
yum install perl
yum install libaio
然后yum安装net-tools yum install net-tools 完成之后就可以顺利安装
4.数据库初始化
mysqld --initialize --user=mysql
查看默认生成的密码:cat /var/log/mysqld.log
红色为默认生成密码
2016-12-07T04:41:58.028558Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2016-12-07T04:41:58.315188Z 0 [Warning] InnoDB: New log files created, LSN=45790
2016-12-07T04:41:58.355114Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2016-12-07T04:41:58.418448Z 0 [Warning] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating a new UUID: 7cc98831-bc37-11e6-a263-000c29f902dc.
2016-12-07T04:41:58.419935Z 0 [Warning] Gtid table is not ready to be used. Table \'mysql.gtid_executed\' cannot be opened.
2016-12-07T04:41:58.420558Z 1 [Note] A temporary password is generated for root@localhost: )1r3gi,hjgQa
启动mysql 现在启动mysql数据库systemctl start mysqld.service
修改密码: mysql> ALTER USER \'root\'@\'localhost\' IDENTIFIED BY \'new_password\';
基本命令:
开启动mysql: systemctl start mysqld.service
进入mysql: mysql -uroot -p
退出mysql: exit或者quit
5.远程连接数据库
开启一个端口
firewall-cmd --zone=public --add-port=端口号/tcp --permanent(--permanent参数为永久生效,不加则重启后失效)
重启端口才会生效
firewall-cmd --reload
开放远程登录权限
mysql> GRANT ALL PRIVILEGES ON *.* TO\'账号\'@\'%\' IDENTIFIED BY \'密码\' WITH GRANT OPTION;
mysql> FLUSH PRIVILEGES;
授权之后,用nevicat检查一下是否可以连接,如果不可以,可能是防火墙限制了,需要开放端口。
1.查看目前防火墙
firewall-cmd --list-all
2.开放3306端口
firewall-cmd --permanent --add-port=3306/tcp
3.重启防火墙
systemctl restart network
4.查看3306端口是否开放
firewall-cmd --query-port=3306/tcp
5.再次查看现在防火墙
firewall-cmd --list-all
6.确认3306端口开放,在阿里云实例安全组中开放3306端口,再次测试使用nevicat远程连接
继续阅读与本文标签相同的文章
吴恩达:企业现在不制定人工智能战略,5年后会后悔
-
第三讲,Ceph内部构件
2026-05-18栏目: 教程
-
日本发明AI女友,中国却发明AI主持人,这就是差距!
2026-05-18栏目: 教程
-
《华西通信》行业深度:Wi-Fi6同步5G启航,共享万物互
2026-05-18栏目: 教程
-
不用纠结NSA与SA网络!对于5G手机来说,体验基本一致
2026-05-18栏目: 教程
-
你对自己的网站拥有所有权吗?
2026-05-18栏目: 教程
