./scripts/mysql_install_db --user=mysql --datadir=/usr/local/mysql/data/mysql
如果执行报错
[root@dc1atmpapp12 mysql]# ./scripts/mysql_install_db --user=mysql --datadir=/usr/local/mysql/data/mysql FATAL ERROR: please install the following Perl modules before executing ./scripts/mysql_install_db: Data::Dumper
解决方法是安装autoconf库
执行命令:yum -y install autoconf
正确执行上面命令以后
cp support-files/mysql.server /etc/init.d/mysqld
chmod 755 /etc/init.d/mysqld
cp support-files/my-default.cnf /etc/my.cnf
2.4.修改启动脚本
vi /etc/init.d/mysqld
2.4.1修改项:
basedir=/usr/local/mysql/
datadir=/usr/local/mysql/data/mysql
2.5.启动服务
service mysqld start
2.6加入环境变量,编辑 /etc/profile,这样可以在任何地方用mysql命令了
export PATH=$PATH:/usr/local/mysql//bin
source /etc/profile
2.7.测试连接
./mysql/bin/mysql -uroot
2.8.启动mysql
service mysqld start
service mysqld status
2.9.创建用户修改root密码并授权
Mysql -uroot -p
set password=password('root');
FLUSH PRIVILEGES;
grant all privileges on *.* to root@"%" identified by 'root' with grant option;
FLUSH PRIVILEGES;