前期 章节
MYSQL源码阅读 一
MYSQL源码阅读 二
LINUX C/C++ 编译库关系
进入安装目录
cd /u01/mysql/mysql8020debug
新建数据库初始化SHELL
vim mysql_initdb.sh
./bin/mysqld --initialize --user=mysql
--basedir=/u01/mysql/mysql8020debug/
--datadir=/u01/mysql/mysql8020debug/data
--character-set-server=UTF8MB4
注意一定要设置字符集UTF8MB4
第二个注意是初始化前DATA目录必须RM -RF 掉
初始化遇到任何ERROR而终止的话,DATA目录也必须RM -RF 掉
然后百度去处理问题
成功如下信息:
[root@localhost mysql8020debug]# sh mysql_initdb.sh
2020-07-10T23:22:03.011126Z 0 [System] [MY-013169] [Server] /u01/mysql/mysql8020debug/bin/mysqld (mysqld 8.0.20-debug) initializing of server in progress as process 3807
2020-07-10T23:22:03.033145Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
2020-07-10T23:22:06.600075Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended.
2020-07-10T23:22:14.145163Z 6 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: YYUgDtrs6*x#
YYUgDtrs6*x#
设置服务模式
进入支持文件夹
cd/u01/mysql/mysql8020debug/support-files
编辑服务文件 mysql.server
另外一个是多实例 mysqld_multi.server
vim mysql.server
basedir=/u01/mysql/mysql8020debug
datadir=/u01/mysql/mysql8020debug/data
另外在207行处
conf=/etc/my.cnf
改成 conf=/u01/mysql/mysql8020debug/my.cnf
保存后复制到服务文件夹中
cp mysql.server /etc/init.d/mysqld
创建配置文件
vim /u01/mysql/mysql8020debug/my.cnf
[mysqld]
basedir=/u01/mysql/mysql8020debug
datadir=/u01/mysql/mysql8020debug/data
character-set-server=UTF8MB4
socket=/tmp/mysql.sock
init_connect='SET NAMES utf8'
join_buffer_size = 128M
sort_buffer_size = 2M
read_rnd_buffer_size = 2M
[mysqld_safe]
pid-file=/u01/mysql/mysql8020debug/mysqld.pid
log-error =/u01/mysql/mysql8020debug/mysql-error.log
#InnoDB#
default-storage-engine=INNODB
innodb_buffer_pool_size=128M
innodb_log_file_size=256M
innodb_log_buffer_size=12M
启动服务:
[root@localhost init.d]# service mysqld start
Starting MySQL.2020-07-10T23:42:54.738179Z mysqld_safe error:
log-error set to '/u01/mysql/mysql8020debug/mysql-error.log',
however file don't exists. Create writable for user 'mysql'.
ERROR! The server quit without updating PID file
(/u01/mysql/mysql8020debug/data/localhost.localdomain.pid).
添加用户,密码和组:
这里添加DBA组, mysql用户 mysql密码
groupadd -g 1000 dba
useradd -u 1100 -g dba -d /home/mysql -s /bin/bash -c "zabbix mysql8.0 Owner" mysql
echo "mysql" | passwd --stdin mysql
设置目录权限
cd /
chown root:dba u01
cd /u01
chown -R mysql:dba mysql/
成功启动服务
[root@localhost u01]# service mysqld start
Starting MySQL... SUCCESS!
[root@localhost u01]# service mysqld stop
Shutting down MySQL.. SUCCESS!
[root@localhost u01]# service mysqld start
登录MYSQL服务里
新开个SHELL窗口 切换到MYSQL用户下
cd /u01/mysql/mysql8020debug
[mysql@localhost mysql8020debug]$ ./bin/mysql -uroot -pYYUgDtrs6*x#
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 8
Server version: 8.0.20-debug
Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql>
注意临时密码有特殊符号需要这样处理 : ./mysql -uroot -p'<6nC&pSfg9Du'
更改ROOT密码
mysql> alter user 'root'@'localhost' identified by "123456" password expire never;
mysql> use mysql
mysql> update user set host='%' where host='localhost';
mysql> flush privileges;