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 -A

Database changed
mysql> update user set host='%' where user ='root';
Query OK, 1 row affected (0.00 sec)
Rows matched: 1  Changed: 1  Warnings: 0

mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值