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
扩展资料
mysql数据库的备份
1、物理冷备份,需要在数据库关闭状态下进行,能够较好的保证数据库的完整性。一般用于非核心业务,这类业务一般都允许终端,物理冷备份的特点就是速度快,恢复 *** 作简单。通常通过直接打包数据库文件夹(如:/usr/local/mysql/data)来实现
2、通过启用二进制日志进行增量备份,MySQL支持增量备份,进行增量备份时必须启用二进制日志。二进制日志文件为用户提供复制,对执行备份点后进行的数据库更改所需的信息进行恢复。如果进行增量备份,需要刷新二进制日志。
参考资料来源:百度百科—mySQL
使用的命令:mysql_install_db,用于初始化mysql的数据库,生成元数据。若不加任何参数,则该命令按照/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.
真正的data目录查找方法:
1、方法一:查找mysql.ini文件
搜索datadir关键词,发现原来路径配置和basedir不一致
datadir="C:/Documents
and
Settings/All
Users/Application
Data/MySQL/MySQL
Server
5.5/Data/"
2、方法二:sql语句
有一条语句可以查找到:
show
variables
like
'datadir'
原来真的没在安装目录下面,竟然在:
C:Documents
and
SettingsAll
UsersApplication
DataMySQLMySQL
Server
5.5data目录下面。
找到了真实的date目录,下面我们就要迁移过来了。
迁移方法:
1、先将MySQL服务停止
2、将之前的data目录复制到目标data文件夹中,覆盖之
3、重启MySQL服务即可。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)