mkdir -p /var/mysql/{data,logs,tmp}
./bin/mysqld --initialize --user=mysql --basedir=/usr/local/mysql --datadir=/var/mysql/data
cp -a ./support-files/mysql.server /etc/init.d/mysql
修改是否允许远程访问、用户密码
use mysql;
update user set host = '%' where user = 'root';
ALTER USER 'root'@'localhost' IDENTIFIED BY '123456';
mysql_ssl_rsa_setup --data-dir=/var/mysql/ --uid=mysql --verbose
mysql --ssl-ca=/var/mysql/ca.pem --ssl-cert=/data0/mysql/client-cert.pem --ssl-key=/var/mysql/client-key.pem -P3306 -uroot -p123456
常用配置
[mysqld]
max_heap_table_size=256M
tmp_table_size=256M
group_concat_max_len=102400
max_allowed_packet=20M
log-bin=mysql-bin
binlog-format=ROW
server_id=1
default-storage-engine = innodb
innodb_file_per_table
collation-server = utf8mb4_general_ci
init-connect = 'SET NAMES utf8mb4'
character-set-server = utf8mb4
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
event_scheduler=ON
备份命令:
mysqldump -uroot -p --databases test> test_20210505.sql
恢复命令:
mysql -uroot -p < test_20210505.sql