mysql数据库,如何进行数据目录的初始化操作
需求描述:
当将mysql的二进制包解压之后,只有通过初始化数据库的数据目录,创建系统表之后才能使用mysql Server
数据库版本:5.5.57-log
操作过程:
1.通过解压之后的mysql包中scripts目录下的mysql_install_db脚本对DB进行初始化
[mysql@redhat6 mysql]$ scripts/mysql_install_db --user=mysql #通过--user=mysql来确定是使用哪个用户来初始化数据库,即通过哪个用户来运行数据库 Installing MySQL system tables... #安装Mysql的系统表 180408 9:56:48 [Warning] option 'slow_query_log': boolean value '/mysql/data/log/slow-query.log' wasn't recognized. Set to OFF. 180408 9:56:48 [Warning] options --log-slow-admin-statements, --log-queries-not-using-indexes and --log-slow-slave-statements have no effect if --log_slow_queries is not set 180408 9:56:48 [Note] Ignoring --secure-file-priv value as server is running with --bootstrap. 180408 9:56:48 [Note] /mysql/mysql/bin/mysqld (mysqld 5.5.57-log) starting as process 2722 ... 180408 9:56:48 [Warning] You need to use --log-bin to make --binlog-format work. OK Filling help tables... #增加help表 180408 9:56:48 [Warning] option 'slow_query_log': boolean value '/mysql/data/log/slow-query.log' wasn't recognized. Set to OFF. 180408 9:56:48 [Warning] options --log-slow-admin-statements, --log-queries-not-using-indexes and --log-slow-slave-statements have no effect if --log_slow_queries is not set 180408 9:56:48 [Note] Ignoring --secure-file-priv value as server is running with --bootstrap. 180408 9:56:48 [Note] /mysql/mysql/bin/mysqld (mysqld 5.5.57-log) starting as process 2729 ... 180408 9:56:48 [Warning] You need to use --log-bin to make --binlog-format work. OK To start mysqld at boot time you have to copy support-files/mysql.server to the right place for your system PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER ! To do so, start the server, then issue the following commands: /mysql/mysql/bin/mysqladmin -u root password 'new-password' #为root用户设置密码 /mysql/mysql/bin/mysqladmin -u root -h redhat6 password 'new-password' Alternatively you can run: /mysql/mysql/bin/mysql_secure_installation which will also give you the option of removing the test databases and anonymous user created by default. This is strongly recommended for production servers. See the manual for more instructions. You can start the MySQL daemon with: cd /mysql/mysql ; /mysql/mysql/bin/mysqld_safe & You can test the MySQL daemon with mysql-test-run.pl cd /mysql/mysql/mysql-test ; perl mysql-test-run.pl Please report any problems at http://bugs.mysql.com/
备注:在我的这个环境中,已经配置了/etc/my.cnf,里面设置datadir选项指明了将data目录存放的位置.
小结:
mysql_install_db脚本的作用就是初始化数据库,创建系统表.
文档创建时间:2018年4月8日21:52:09