INSTALL MYSQL db STEPS

https://downloads.mysql.com/archives/community/

mkdir /usr/local/mysq
mkdir /home/data

groupadd mysql
useradd -r -s /sbin/nologin -g mysql mysql -d /usr/local/mysql

cd /usr/local/mysql

#pwd
#chown -R mysql .
#chgrp -R mysql .

chown -R mysql /home/data/mysql


# bin/mysqld --initialize --user=mysql --basedir=/usr/local/mysql --datadir=/home/data/mysql

[root@TEST01104 mysql]# bin/mysqld --initialize --user=mysql --basedir=/usr/local/mysql --datadir=/home/data/mysql
2021-03-29T09:09:40.726431Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2021-03-29T09:09:51.552708Z 0 [Warning] InnoDB: New log files created, LSN=45790
2021-03-29T09:09:53.091280Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2021-03-29T09:09:53.227368Z 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: 85e7777d-906e-11eb-8282-0050569f07a4.
2021-03-29T09:09:53.241973Z 0 [Warning] Gtid table is not ready to be used. Table ‘mysql.gtid_executed‘ cannot be opened.
2021-03-29T09:09:53.242937Z 1 [Note] A temporary password is generated for root@localhost: MsT)%<&=;6zW


temppassword:MsT)%<&=;6zW


MsT)%<&=;6zW
#bin/mysql_ssl_rsa_setup --datadir=/home/data/mysql

[root@TEST01104 mysql]# bin/mysql_ssl_rsa_setup --datadir=/home/data/mysql
Generating a 2048 bit RSA private key
...........................................+++
...........................................+++
writing new private key to ‘ca-key.pem‘
-----
Generating a 2048 bit RSA private key
.....+++
.........................................................+++
writing new private key to ‘server-key.pem‘
-----
Generating a 2048 bit RSA private key
..+++
..........+++
writing new private key to ‘client-key.pem‘
-----


cd support-files

ls -lrt /etc/my.cnf
ls -lrt /etc/init.d/mysql
cp /etc/my.cnf /etc/my.cnf.20210329

cp /etc/init.d/mysql /etc/init.d/mysql.20210329
# cp my-default.cnf /etc/my.cnf
# cp mysql.server /etc/init.d/mysql

vim /etc/init.d/mysql

Basedir=/usr/local/mysql
Datadir=/home/data/mysql


# vim /etc/my.cnf
vi /etc/my.cnf
port=3306
socket=/usr/local/mysql/mysql.sock
[mysql]
no-auto-rehash

socket=/usr/local/mysql/mysql.sock
basedir=/usr/local/mysql
max_allowed_packet=32M
datadir=/home/data/mysql
explicit_defaults_for_timestamp =true
skip-ssl
#secure-file-priv=null
#lower_case_table_names=1
back_log=300
max_connections=3000
max_connect_errors=100
table_open_cache=4096
external_locking=FALSE
max_allowed_packet=32M
sort_buffer_size=16M
join_buffer_size=16M
thread_cache_size=16
query_cache_size=128M
query_cach_limit=4M
character-set-server = utf8mb4


启动mysql:
cd /usr/local/mysql

#bin/mysqld_safe --user=mysql &

bin/mysql --user=root –p


/usr/local/mysql/bin/mysql -u root -p

 


ERROR 2002 (HY000): Can‘t connect to local MySQL server through socket ‘/tmp/mysql.sock‘ (2)
fix:

ln -s /usr/local/mysql/mysql.sock /tmp/mysql.sock


set password=password(‘A123456‘);

root A123456

grant all privileges on *.* to root@‘%‘ identified by ‘A123456‘;

 




##restart mysql
sudo /etc/init.d/mysql restart

 

INSTALL MYSQL db STEPS

上一篇:Oracle约束


下一篇:Django之 mysql相关配置