当前位置:网站首页>Zhangxiaobai takes you to install MySQL 5.7 on Huawei cloud ECS server

Zhangxiaobai takes you to install MySQL 5.7 on Huawei cloud ECS server

2022-06-12 00:12:00 Hua Weiyun

Hua Wei Yun ECS Server after purchase , There will be a built-in similar MySQL The database of , be called mariadb.

In general , If you want to use MySQL, It is better to replace this database , The following is Zhang Xiaobai's replacement practice with reference to the introduction on the Internet .

Use root Sign in , see mariadb Version of :

Delete mariadb:

see MySQL Whether to install :

download MySQL5.7.37 Code package for :

cd /usr/local

wget https://cdn.mysql.com/Downloads/MySQL-5.7/mysql-5.7.37-el7-x86_64.tar.gz

decompression :

tar -zxvf mysql-*.gz

mv mysql-5.7.37-el7-x86_64 mysql

Set the permissions :
chown -R mysql:mysql /usr/local/mysql
chmod -R 755 /usr/local/mysql
mkdir -p /data/mysql/data
mkdir -p /data/mysql/logs
mkdir -p /data/mysql/tmp
chown -R mysql:mysql  /data/mysql

edit /etc/my.cnf file :

[client]port = 3306socket = /data/mysql/tmp/mysql.sock[mysqld]user = mysqlbasedir = /usr/local/mysql datadir = /data/mysql/data port = 3306 socket = /data/mysql/tmp/mysql.sockpid-file = /data/mysql/tmp/mysqld.pidtmpdir = /data/mysql/tmp skip_name_resolve = 1symbolic-links=0max_connections = 2000group_concat_max_len = 1024000sql_mode = NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTIONlower_case_table_names = 1log_timestamps=SYSTEMcharacter-set-server = utf8interactive_timeout = 1800 wait_timeout = 1800max_allowed_packet = 32Mbinlog_cache_size = 4Msort_buffer_size = 2Mread_buffer_size = 4Mjoin_buffer_size = 4Mtmp_table_size = 96Mmax_heap_table_size = 96Mmax_length_for_sort_data = 8096#logsserver-id = 1003306log-error = /data/mysql/logs/error.logslow_query_log = 1slow_query_log_file = /data/mysql/logs/slow.loglong_query_time = 3log-bin = /data/mysql/logs/binlogbinlog_format = rowexpire_logs_days = 15log_bin_trust_function_creators = 1relay-log = /data/mysql/logs/relay-binrelay-log-recovery = 1 relay_log_purge = 1 #innodb innodb_file_per_table = 1innodb_log_buffer_size = 16Minnodb_log_file_size = 256Minnodb_log_files_in_group = 2innodb_io_capacity = 2000innodb_io_capacity_max = 4000innodb_flush_neighbors = 0innodb_flush_method = O_DIRECTinnodb_autoinc_lock_mode = 2innodb_read_io_threads = 8innodb_write_io_threads = 8innodb_buffer_pool_size = 2G

take mysql Set to linux service :

cd /usr/local/mysql/support-files

cp mysql.server /etc/init.d/mysql

edit /etc/init.d/mysql file :

Set the following two lines :

basedir=/usr/local/mysql
datadir=/data/mysql/data

chkconfig --add mysql

chkconfig --list

Edit environment variables :

echo "PATH=$PATH:/usr/local/mysql/bin " >> /etc/profile 

source /etc/profile

Manual start MySQL:

Report errors !

Need to install libaio software package :

rpm -qa|grep libaio 

yum install  libaio-devel.x86_64

Start again MySQL Try :

The string of characters indicated by the arrow above is temporary root password .

restart MySQL:

service stop mysql

service start mysql

Sign in MySQL Command line :

mysql -uroot -p

Enter the previous temporary password to enter the command line .

modify root password :

alter user 'root'@'localhost' identified by 'xxxxxx';

flush privileges;

quit Exit the command line .

ln -s /usr/local/mysql/bin/mysql /usr/bin/mysql

You can restart again MySQL:

service restart mysql

After that, you can use the new password to log in at the command line .

If you want to use remote login , The following needs to be modified :

grant all privileges on *.* to'root'@'%' identify by 'xxxxxx' with grant option; 

flush privileges;

Restart again MySQL that will do .

( The full text after , Thank you for reading )

原网站

版权声明
本文为[Hua Weiyun]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/03/202203011529392512.html