在实际开发中,我们往往需要在linux上安装mysql数据库。这里我们教授大家使用yum的方式快速安装mysql,注意安装前需保证linux机器能够上网。
1、yum install mysql mysql-server mysql-devel
2、完成后,启动mysql
/etc/init.d/mysqld start
3、启动mysql控制台:
mysql -uroot -p
4、在mysql控制台中进行如下一些操作
mysql>; USE mysql;
mysql>; UPDATE user SET Password=PASSWORD('这里设置root用户新密码') WHERE user='root';
mysql>; FLUSH PRIVILEGES;
允许远程登录
mysql -u root -p
Enter Password: <your new password>
mysql>GRANT ALL PRIVILEGES ON *.* TO '用户名'@'%' IDENTIFIED BY '密码' WITH GRANT OPTION;
完成后就能远程管理mysql了。
需要注意的是
通过这种方法安装的mysql数据库,默认mysql服务名字为mysqld
service mysqld start
把数据库加入开机自启动项目:
chkconfig mysqld on