若不加任何参数,则该命令按照/etc/my.cnf文件配置执行初始化工作,否则可参照如下帮助手动执行参数。
$ mysql_install_db --help 可以查看帮助信息如下
Usage: /usr/local/mysql/bin/mysql_install_db [OPTIONS]
--basedir=path The path to the MySQL installation directory.
--cross-bootstrapFor internal use. Used when building the MySQL system
tables on a different host than the target.
--datadir=path The path to the MySQL data directory.
--force Causes mysql_install_db to run even if DNS does not
work. In that case, grant table entries that normally
use hostnames will use IP addresses.
--ldata=path The path to the MySQL data directory.
--rpmFor internal use. This option is used by RPM files
during the MySQL installation process.
--skip-name-resolve Use IP addresses rather than hostnames when creating
grant table entries. This option can be useful if
your DNS does not work.
--srcdir=pathFor internal use. The directory under which
mysql_install_db looks for support files such as the
error message file and the file for popoulating the
help tables.
--user=user_name The login username to use for running mysqld. Files
and directories created by mysqld will be owned by this
user. You must be root to use this option. By default
mysqld runs using your current login name and files and
directories that it creates will be owned by you.
初始化mysql数据库,在shell中运行以下命令:
cd /usr/local/mysql
mkdir sock
cd /usr/local/mysql/bin
初始化数据库
./mysql_install_db--user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data
或者# mysqld --initialize
当在Ubuntu中执行命令sudo apt-get install mysql-server5.1安装的时候居然没有提示我输入mysql的密码之类的信息,但是当安装好之后再终端中直接输入mysql的时候又能直接进入mysql中,虽然可以进入mysql中但是我对mysql的密码一点都不知道,所以这个时候安装的mysql就相当于没有安装,因为不能用程序进行 *** 作mysql数据库(因为 *** 作数据库都需要mysql数据的密码的),为了解决ubuntu中mysql密码初始化的方法有一下两种:
(1)打开/etc/mysql/debian.cnf文件,在这个文件中有系统默认给我们分配的用户名和密码,通过这个密码就可以直接对mysql进行 *** 作了。但是一般这个密码都比较怪,很长很长。
(2)当进入mysql之后修改mysql的密码:这个方法比较好,具体的 *** 作如下用命令:set password for 'root'@'localhost' = password('yourpass')当修改之后就可应正常对mysql进行 *** 作了。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)