Linux common users install MySQL database, mysql-5.7.24 version, ContOS8 version server

Ordinary Linux users install mylsq, and some configurations and problems are solved with the root user.
First check whether mysql has been installed but not uninstalled cleanly, check the installation of MySQL and mariadb, and uninstall if there is one. This installation is installed on CentOS8:

mysql-5.7.24-el7-x86_64 download
Extraction code: wigp

First log in as the root user, check the machine installation, and create a normal user:

Check:

rpm -qa | grep mysql
rpm -qa | grep mariadb

Uninstall the original if it exists:
rpm -e --nodeps uninstall name

rpm -e --nodeps mariadb-libs-5.5.56-2.el7.x86_64

Add the mysql user and modify the login password of the mysql user:

useradd mysql
passwd mysql

insert image description here
Edit configuration file:

vi /etc/my.cnf

insert image description here

The inserted content is as follows:

[client]
port = 3306
socket = /tmp/mysql.sock

[mysqld]
user=mysql
basedir=/home/mysql
datadir=/home/mysql/data
port=3306               
socket=/tmp/mysql.sock
pid-file=/tmp/mysql.pid
tmpdir=/tmp
skip_name_resolve = 1
symbolic-links=0
max_connections = 2000
group_concat_max_len = 1024000
sql_mode = NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION
lower_case_table_names = 1
explicit_defaults_for_timestamp=true
character-set-server = utf8
interactive_timeout = 120  
wait_timeout = 120
max_allowed_packet = 32M
binlog_cache_size = 4M
sort_buffer_size = 2M
read_buffer_size = 4M
join_buffer_size = 4M
tmp_table_size = 96M
max_heap_table_size = 96M
max_length_for_sort_data = 8096
key_buffer_size = 256M
query_cache_size = 256M
query_cache_type = 1
query_cache_limit = 50M
max_connect_errors = 20
thread_cache_size = 200
innodb_flush_log_at_trx_commit = 1
max_binlog_cache_size = 512M
max_binlog_size = 512M
read_rnd_buffer_size = 64M
bulk_insert_buffer_size = 128M

server-id = 25
log-error = /home/mysql/log/error.log
slow_query_log = 1
slow_query_log_file = /home/mysql/log/slow.log
long_query_time = 3
log-bin = /home/mysql/log/binlog
binlog_format = row
expire_logs_days = 7
log_bin_trust_function_creators = 1
relay-log = /home/mysql/log/relay-bin
relay-log-recovery = 1  
relay_log_purge = 1  

innodb_file_per_table = 1
innodb_log_buffer_size = 16M
innodb_log_file_size = 256M
innodb_log_files_in_group = 5
innodb_io_capacity = 2000
innodb_io_capacity_max = 4000
innodb_flush_neighbors = 0
innodb_flush_method = O_DIRECT
innodb_autoinc_lock_mode = 2
innodb_read_io_threads = 8
innodb_write_io_threads = 8
innodb_buffer_pool_size = 2G

transaction_isolation = READ-COMMITTED

After the above steps are completed, switch the mysql user:

su - mysql

Use tools to put mysql-5.7.24-el7-x86_64.tar.gz into /home/mysql to decompress:

tar -zxvf mysql-5.7.24-el7-x86_64.tar.gz

insert image description here
Move all the contents of the decompressed mysql-5.7.24-el7-x86_64 file to the /home/mysql folder:

mv /home/mysql/mysql-5.7.24-el7-x86_64/* /home/mysql/

insert image description here
Edit mysql.server to add basedir and datadir paths:

vi /home/mysql/support-files/mysql.server

Supplement:
basedir=/home/mysql
datadir=/home/mysql/data
insert image description here
creates a log directory:

mkdir /home/mysql/log

insert image description here
Enter the bin directory:

cd /home/mysql/bin/

Initialize MySQL:

./mysqld --initialize --user=mysql --basedir=/home/mysql --datadir=/home/mysql/data

insert image description here
Configure ssl and rsa keys:

./mysql_ssl_rsa_setup  --datadir=/home/mysql/data

insert image description here
Edit the mysql command configuration:

vi ~/.bash_profile

Add at the bottom:
export PATH=$PATH:/home/mysql/bin
insert image description here
Refresh configuration:

source ~/.bash_profile

Switch to the root user and copy the mysql startup script file to the /etc/init.d/ directory:

su - root
cp /home/mysql/support-files/mysql.server /etc/init.d/mysql

insert image description here
Switch back to the mysql user, and check the initial password of the database root user in the log:

su - mysql
cat /home/mysql/log/error.log

insert image description here
start up:

service mysql start

insert image description here
Use the database root user to log in, and the password is the initial password viewed in the log:

mysql -uroot -p

If you encounter the following problems:
mysql: error while loading shared libraries: libncurses.so.5: cannot open shared object file: No such file or directory
insert image description here
Method 1:
If you are connected to the Internet or have a yum source, you can directly install the missing packages:

yum install libncurses* -y

Method 2:
Use offline or without yum source:

Switch root user:

su - root
cp /lib64/libncurses.so.6 /lib64/libncurses.so.5

or soft link

ln -s /lib64/libncurses.so.6 /lib64/libncurses.so.5

insert image description here
There may also be the following problems:
mysql: error while loading shared libraries: libtinfo.so.5: cannot open shared object file: No such file or directory
insert image description here
Switch root user:

su - root
cp /lib64/libtinfo.so.6 /lib64/libtinfo.so.5

or soft link

ln -s /lib64/libtinfo.so.6 /lib64/libtinfo.so.5

insert image description here
Switch back to the mysql user and continue to log in:

su - mysql
mysql -uroot -p

insert image description here
After successful login, change the password:

set password=password("root123");
update mysql.user set authentication_string = password("root123") where user='root';

insert image description here
Refresh configuration:

flush privileges;

insert image description here
Authorize external visualizer connection login:

GRANT ALL PRIVILEGES ON *.* TO 'root'@'%'IDENTIFIED BY 'root123' WITH GRANT OPTION;

insert image description here
Refresh configuration:

flush privileges;

insert image description here
If the visualization tool cannot connect, check whether it is a firewall problem: check
the firewall status
systemctl status firewalld.service
temporarily enable the firewall
systemctl start firewalld.service
temporarily close the firewall
systemctl stop firewalld.service
start to disable the firewall
systemctl disable firewalld.service
start the firewall
systemctl enable firewalld.service

----------------------------------------------Dividing line-- --------------------------------------------
Log in with the MySQL database root user , add a common database user:

 mysql -uroot -p
CREATE USER 'mysql'@'localhost' IDENTIFIED BY 'mysql123';

insert image description here
Update password:

update mysql.user set authentication_string = password("mysql123") where user='mysql';

insert image description here

Authorize external visualizer connection login:

GRANT ALL PRIVILEGES ON *.* TO 'mysql'@'%'IDENTIFIED BY 'mysql123' WITH GRANT OPTION;

insert image description here
Refresh configuration:

flush privileges;

insert image description here

Supongo que te gusta

Origin blog.csdn.net/qq_41619841/article/details/123083464
Recomendado
Clasificación