openEuler下安装mysql
环境:
Os:openEuler 2203sp4
1.1 介质准备
mysql-5.7.29-linux-glibc2.12-x86_64.tar.gz
该介质可以从官网上进行下载
1.1 创建mysql用户和用户组
root@ecs-d7c2-0417412 ~]#groupadd mysql
root@ecs-d7c2-0417412 ~]#useradd mysql -s /sbin/nologin -M -g mysql
1.1 下载解压二进制文件,解压,进入解压出来的文件
[root@localhost soft]# tar -xvf mysql-5.7.29-linux-glibc2.12-x86_64.tar.gz
[root@localhost soft]# mv mysql-5.7.29-linux-glibc2.12-x86_64 /opt/mysql57
[root@localhost soft]# cd /opt/mysql57
[root@localhost mysql5733]# ls
bin docs include lib LICENSE man README share support-files
1.1 在mysql主目录下建立相应的目录
data目录存放数据文件,conf目录存放配置文件
[root@localhost mysql5733]#cd /opt/mysql57
[root@localhost mysql5733]#mkdir data ##数据文件目录
[root@localhost mysql5733]#mkdir conf ## 配置文件目录
[root@localhost mysql5733]#mkdir -p mysqllog/relaylog ##主从环境relaylog
[root@localhost mysql5733]#mkdir -p mysqllog/logfile ##错误日志文件
[root@localhost mysql5733]#mkdir -p mysqllog/binlog ##binlog文件
[root@localhost mysql5733]#mkdir -p secure_file ##secure_file_priv参数指定路
1.1 在conf目录下创建配置文件my.cnf,配置文件内容如下
[mysqld]
port=13306
server-id=1
basedir=/opt/mysql57
datadir=/opt/mysql57/data
max_connections = 10000
character_set_server=utf8mb4
collation-server=utf8mb4_general_ci
init_connect='SET collation_connection = utf8mb4_general_ci'
init_connect='SET NAMES utf8mb4'
interactive_timeout=86400
wait_timeout=86400
skip-external-locking
key_buffer_size= 128M
max_allowed_packet=32M
query_cache_size=32M
read_buffer_size=2M
sort_buffer_size=1M
join_buffer_size= 128M
innodb_file_per_table= 1
innodb_open_files= 5000
innodb_buffer_pool_size= 24G
innodb_write_io_threads= 16
innodb_read_io_threads= 16
innodb_thread_concurrency = 0
innodb_purge_threads= 1
innodb_flush_log_at_trx_commit= 2
innodb_log_buffer_size=16M
innodb_log_file_size=512M
innodb_log_files_in_group= 5
innodb_max_dirty_pages_pct= 90
innodb_lock_wait_timeout= 120
bulk_insert_buffer_size= 64M
myisam_sort_buffer_size=64M
myisam_max_sort_file_size= 10G
myisam_repair_threads= 1
log_bin_trust_function_creators=1
event_scheduler=1
max_binlog_size=100M
binlog_format=row
log-bin=/opt/mysql57/mysqllog/binlog/binlog.bin
slow_query_log=on
slow_query_log_file=/opt/mysql57/mysqllog/logfile/slow-query.log
long_query_time=1
log_queries_not_using_indexes=on
log-error=/opt/mysql57/mysqllog/logfile/mysql-err.log
binlog_cache_size=4MB
skip-host-cache
skip-name-resolve
expire_logs_days=15
skip-slave-start
relay-log-index=/opt/mysql57/mysqllog/relaylog/slave-relay-bin.index
relay-log=/opt/mysql57/mysqllog/relaylog/relaylog-binlog
replicate-ignore-db=information_schema,performance_schema,sys
slave_net_timeout=60
language=/opt/mysql57/share/english
early-plugin-load=""
explicit_defaults_for_timestamp=true
log_slave_updates=1
gtid_mode=ON
enforce_gtid_consistency = ON
lower_case_table_names=1
sql_mode='STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION'
secure_file_priv=/opt/mysql57/secure_file
[client]
port = 13306
default-character-set = utf8mb4
[mysqldump]
quick
max_allowed_packet = 32M
[myisamchk]
key_buffer_size = 8M
sort_buffer_size = 8M
read_buffer = 4M
write_buffer = 4M
1.1 修改mysql目录权限
[root@localhost opt]#cd /opt/
[root@localhost opt]# chown -R mysql:mysql ./mysql57
1.1 初始化数据库
./mysqld --initialize --user=mysql --basedir=/opt/mysql57 --datadir=/opt/mysql57/data --lc_messages_dir=/opt/mysql57/share --lc_messages=en_US
[root@localhost bin]# ./mysqld --initialize --user=mysql --basedir=/opt/mysql57 --datadir=/opt/mysql57/data --lc_messages_dir=/opt/mysql57/share --lc_messages=en_US
2023-02-21T08:33:45.882623Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2023-02-21T08:33:46.128462Z 0 [Warning] InnoDB: New log files created, LSN=45790
2023-02-21T08:33:46.178250Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2023-02-21T08:33:46.240176Z 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: 74f5f6a5-b1c2-11ed-b523-fa163eb498c0.
2023-02-21T08:33:46.242139Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
2023-02-21T08:33:46.704581Z 0 [Warning] CA certificate ca.pem is self signed.
2023-02-21T08:33:46.758569Z 1 [Note] A temporary password is generated for root@localhost: r:J9*kd-</i6
1.1 启动
[mysql@localhost bin]$ /opt/mysql57/bin/mysqld_safe --defaults-file=/opt/mysql57/conf/my.cnf --user=mysql &
[root@localhost opt]#echo>/opt/mysql57/mysqllog/logfile/mysql-err.log
[root@localhost opt]#cd /opt/
[root@localhost opt]# chown -R mysql:mysql ./mysql57
1.1 登陆mysql并修改密码
[root@19c opt]# /opt/mysql57/bin/mysql -h localhost -uroot -P13306 -p
/opt/mysql57/bin/mysql: error while loading shared libraries: libncurses.so.5: cannot open shared object file: No such file or directory
[root@19c ios]# find / -name libncurses.so*
/usr/lib64/libncurses.so.6.3
/usr/lib64/libncurses.so.6
建立一个软连接
ln -s /usr/lib64/libncurses.so.6.3 /usr/lib64/libncurses.so.5
[root@19c opt]# /opt/mysql57/bin/mysql -h localhost -uroot -P13306 -p
/opt/mysql57/bin/mysql: error while loading shared libraries: libtinfo.so.5: cannot open shared object file: No such file or directory
[root@19c opt]#
[root@19c ios]# find / -name libtinfo.so*
/usr/lib64/libtinfo.so.6.3
/usr/lib64/libtinfo.so.6
建立一个软连接
ln -s /usr/lib64/libtinfo.so.6.3 /usr/lib64/libtinfo.so.5
修改密码
mysql> set password=password('mysql');
删除系统自带用户(看实际情况需要)
mysql> delete from mysql.user where user='mysql.session';
Query OK, 1 row affected (0.06 sec)
mysql> delete from mysql.user where user='mysql.sys';
Query OK, 1 row affected (0.06 sec)
1.1 重启
su - root
/opt/mysql57/bin/mysqladmin -h localhost -uroot -P13306 -pmysql shutdown
/opt/mysql57/bin/mysqladmin -h localhost -uroot -P13306 -p shutdown
/opt/mysql57/bin/mysqld_safe --defaults-file=/opt/mysql57/conf/my.cnf --user=mysql &
1.1 正常登录
/opt/mysql57/bin/mysql -h localhost -uroot -P13306 -p