下载并解压
[root@openeuler ~]
[root@openeuler ~]
更改路径
[root@openeuler ~]
[root@openeuler ~]
bin docs include lib LICENSE man README share support-files
创建数据存放目录和用户,并修改目录权限
[root@openeuler ~]
[root@openeuler ~]
[root@openeuler ~]
初始化数据库
[root@openeuler ~]
[root@openeuler mysql]
2025-01-06T02:40:17.844382Z 0 [System] [MY-013169] [Server] /usr/local/mysql/bin/mysqld (mysqld 8.0.11) initializing of server in progress as process 53943
2025-01-06T02:40:19.301346Z 5 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: (wat
2025-01-06T02:40:20.094478Z 0 [System] [MY-013170] [Server] /usr/local/mysql/bin/mysqld (mysqld 8.0.11) initializing of server has completed
配置环境变量
[root@openeuler mysql]
export MYSQL_HOME=/usr/local/mysql
export PATH=$PATH:$MYSQL_HOME/bin
[root@openeuler mysql]
修改配置文件my.cnf
[root@openeuler mysql]
[mysqld]
basedir = /usr/local/mysql
datadir = /usr/local/mysql/data
socket = /usr/local/mysql/mysql.sock
character-set-server=utf8
port = 3306
bind-address = 0.0.0.0
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
[client]
socket = /usr/local/mysql/mysql.sock
default-character-set=utf8
配置MySQL服务
[root@openeuler mysql]
[root@openeuler mysql]
[root@openeuler mysql]
配置用Systemctl来管理Mysql
[root@openeuler mysql]
[Unit]
Description=MySQL Server
Documentation=man:mysqld(8)
Documentation=http://dev.mysql.com/doc/refman/en/using-systemd.html
After=network.target
After=syslog.target
[Install]
WantedBy=multi-user.target
[Service]
User=mysql
Group=mysql
ExecStart=/usr/local/mysql/bin/mysqld --defaults-file=/etc/my.cnf
LimitNOFILE = 5000
[root@openeuler mysql]
[root@openeuler mysql]
[root@openeuler mysql]
[root@openeuler mysql]
[root@openeuler mysql]
Created symlink /etc/systemd/system/multi-user.target.wants/mysql.service → /usr/lib/systemd/system/mysql.service.
[root@openeuler mysql]
● mysql.service - MySQL Server
Loaded: loaded (/usr/lib/systemd/system/mysql.service; enabled; preset: disabled)
Active: active (running) since Mon 2025-01-06 10:54:42 CST; 1min 27s ago
Docs: man:mysqld(8)
http://dev.mysql.com/doc/refman/en/using-systemd.html
Main PID: 54359 (mysqld)
Tasks: 36 (limit: 21560)
Memory: 364.5M ()
CGroup: /system.slice/mysql.service
└─54359 /usr/local/mysql/bin/mysqld --defaults-file=/etc/my.cnf
验证
[root@openeuler mysql]
mysql: error while loading shared libraries: libtinfo.so.5: cannot open shared object file: No such file or directory
[root@openeuler mysql]
......
Package ncurses-libs-6.4-8.oe2403.x86_64 is already installed.
Dependencies resolved.
Nothing to do.
Complete!
[root@openeuler mysql]
mysql: error while loading shared libraries: libtinfo.so.5: cannot open shared object file: No such file or directory
[root@openeuler mysql]
[root@openeuler mysql]
mysql Ver 8.0.11 for linux-glibc2.12 on x86_64 (MySQL Community Server - GPL)
登录数据库并修改密码
[root@openeuler mysql]
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 10
Server version: 8.0.11
Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '123456';
Query OK, 0 rows affected (0.10 sec)
mysql> exit
Bye
[root@openeuler mysql]
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 12
Server version: 8.0.11 MySQL Community Server - GPL
Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql>
配置数据库远程登录
[root@openeuler mysql]
mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' WITH GRANT OPTION;
Query OK, 0 rows affected (0.04 sec)
mysql> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.00 sec)
mysql> ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY '123456';
Query OK, 0 rows affected (0.10 sec)
mysql> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.01 sec)
mysql> exit
Bye