centos8安装mysql8.0
2021/9/20 19:28:58
本文主要是介绍centos8安装mysql8.0,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!
一、mysql安装包下载:
下载安装文档:MySQL :: MySQL 8.0 Reference Manual :: 2.2 Installing MySQL on Unix/Linux Using Generic Binaries
下载页面:MySQL :: Download MySQL Community Server
wget https://dev.mysql.com/get/Downloads/MySQL-8.0/mysql-8.0.26-linux-glibc2.12-x86_64.tar.xz
二、解压:
xz -d mysql-8.0.26-linux-glibc2.12-x86_64.tar.xz
解压tar包:
tar -xvf mysql-8.0.26-linux-glibc2.12-x86_64.tar -C /opt/mysql
前提需要/opt/mysql目录已经存在
cd /opt/mysql mv mysql-8.0.26-linux-glibc2.12-x86_64 mysql-8.0.26 cd mysql-8.0.26 mkdir data #编辑配置文件 vim /etc/my.cnf
[mysql] default-character-set=utf8 [mysqld] skip-name-resolve port=3306 basedir=/opt/mysql/mysql-8.0.26 datadir=/opt/mysql/mysql-8.0.26/data character-set-server=utf8 default-storage-engine=innodb max_allowed_packet=32M
三、参照官方文档进行初始化:
[root@192 mysql-8.0.26]# bin/mysqld --initialize
2021-09-20T02:30:38.227555Z 0 [System] [MY-013169] [Server] /opt/mysql/mysql-8.0.26/bin/mysqld (mysqld 8.0.26) initializing of server in progress as process 24355
2021-09-20T02:30:38.229082Z 0 [Warning] [MY-013242] [Server] --character-set-server: 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous.
2021-09-20T02:30:38.240237Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
2021-09-20T02:30:38.671648Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended.
2021-09-20T02:30:39.724283Z 0 [Warning] [MY-013746] [Server] A deprecated TLS version TLSv1 is enabled for channel mysql_main
2021-09-20T02:30:39.724790Z 0 [Warning] [MY-013746] [Server] A deprecated TLS version TLSv1.1 is enabled for channel mysql_main
2021-09-20T02:30:39.773235Z 6 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: WgqAwrysI1.&
[root@192 mysql-8.0.26]# bin/mysql_ssl_rsa_setup [root@192 mysql-8.0.26]# bin/mysqld_safe --user=root &
[1] 24405
[root@192 mysql-8.0.26]# Logging to '/opt/mysql/mysql-8.0.26/data/192.168.127.147.err'.
2021-09-20T02:31:34.764783Z mysqld_safe Starting mysqld daemon with databases from /opt/mysql/mysql-8.0.26/data
四、连接mysql:
[root@192 mysql-8.0.26]# bin/mysql -uroot -pWgqAwrysI1.& [2] 24626 [root@192 mysql-8.0.26]# bin/mysql: error while loading shared libraries: libtinfo.so.5: cannot open shared object file: No such file or directory
centos8环境下可能会报如上错误
解决办法:
sudo ln -s /usr/lib64/libtinfo.so.6.1 /usr/lib64/libtinfo.so.5
重新连接:
[root@192 mysql-8.0.26]# bin/mysql -uroot -p #输入密码连接成功
五、修改密码:
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'root';
Query OK, 0 rows affected (0.00 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
六、配置远程连接
mysql> use mysql;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -ADatabase changed
mysql> update user set host='%' where user ='root';
Query OK, 1 row affected (0.00 sec)
Rows matched: 1 Changed: 1 Warnings: 0mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
这篇关于centos8安装mysql8.0的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!
- 2024-12-25如何部署MySQL集群资料:新手入门教程
- 2024-12-24MySQL集群部署资料:新手入门教程
- 2024-12-24MySQL集群资料详解:新手入门教程
- 2024-12-24MySQL集群部署入门教程
- 2024-12-24部署MySQL集群学习:新手入门教程
- 2024-12-24部署MySQL集群入门:一步一步搭建指南
- 2024-12-07MySQL读写分离入门:轻松掌握数据库读写分离技术
- 2024-12-07MySQL读写分离入门教程
- 2024-12-07MySQL分库分表入门详解
- 2024-12-07MySQL分库分表入门指南