在linux下用二进制方式安装mysql8
华为欧拉操作系统版本:openEuler 20.03-LTS-SP4
因为我用的笔记本安装的,需要无线网卡驱动,所以采用的这个版本,高版本无法识别无线网卡驱动
rpm -qa | grep mariadb
rpm -e --nodeps mariadb-connector-c-3.0.6-9.oe2003sp4.x86_64
mkdir /usr/local/mysql
cd /usr/local/mysql
wget https://cdn.mysql.com/archives/mysql-8.0/mysql-8.0.18-linux-glibc2.12-x86_64.tar.xz
tar xvJf mysql-8.0.18-linux-glibc2.12-x86_64.tar.xz
mv mysql-8.0.18-linux-glibc2.12-x86_64 mysql8.0
mkdir /usr/local/mysql/mysql8.0/data
groupadd mysql
useradd -g mysql mysql
chown -R mysql.mysql /usr/local/mysql/mysql8.0/
cd mysql8.0/bin
./mysqld --user=mysql --basedir=/usr/local/mysql/mysql8.0 --datadir=/usr/local/mysql/mysql8.0/data/ --initialize
2024-11-19T14:30:31.547633Z 0 [System] [MY-013169] [Server] /usr/local/mysql/mysql8.0/bin/mysqld (mysqld 8.0.18) initializing of server in progress as process 1570
2024-11-19T14:30:35.546952Z 5 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: muaQVm3kfc#h
这个muaQVm3kfc#h就是mysql的初始密码
cd ../
cp -a ./support-files/mysql.server /etc/init.d/mysql
chmod +x /etc/init.d/mysql
chkconfig --add mysql
去编辑 etc下的profile文件,在最底下添加下面这行
PATH=/usr/local/mysql/mysql8.0/bin:/usr/local/mysql/mysql8.0/lib:$PATH
source /etc/profile
ln -s /usr/local/mysql/mysql8.0/bin/mysql /usr/bin
ln -s /usr/local/mysql/mysql8.0/bin/my_print_defaults /usr/bin
my.cnf文件内容如下,放在/etc目录下
[mysqld]
basedir=/usr/local/mysql/mysql8.0
datadir=/usr/local/mysql/mysql8.0/data
default-storage-engine=INNODB
character-set-server=utf8mb4
collation-server=utf8mb4_general_ci
port=3306
socket=/tmp/mysql.sock
service mysql start
mysql -u root -p
然后输入mysql的默认初始密码
muaQVm3kfc#h
修改mysql密码
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'mysql80_123456';
FLUSH PRIVILEGES;
use mysql
update user set user.Host='%'where user.User='root';
FLUSH PRIVILEGES;
exit;
firewall-cmd --zone=public --add-port=3306/tcp --permanent
firewall-cmd --reload