[root@localhost ~]#yum list installed mysql*[root@localhost ~]#rpm –qa|grep mysql*
[root@localhost ~]#yum list mysql*
[root@localhost ~]yum install mysql
[root@localhost ~]#yum install mysql-server[root@localhost ~]#yum install mysql-devel
[root@localhost ~]#vim /etc/my.cnf
[root@localhost ~]#service mysqld start --启动mysql 或者 /etc/init.d/mysqld start (关闭mysql #service mysql stop)
\7. 設定開機啟動mysql服務
[root@localhost ~]# chkconfig --add mysqld
\ 8. 建立root使用者密碼為123456
mysqladmin –u root password 123456
[root@localhost ~]# mysqladmin -u root password 123456
\9. 連結mysql
[root@localhost ~]# mysql -u root -p --输入密码123456
mysql> use mysql mysql> GRANT ALL PRIVILEGES ON *.* TO ‘admin’@’%’IDENTIFIED BY ‘admin’ WITH GRANT OPTION; --第一个admin为用户名,第二个admin为密码,%表示所有的电脑都可以链接 mysql> flush privileges; --设置立即生效
mysql> SELECT DISTINCT CONCAT('User:''',user,'''@''',host,''';') AS query FROM mysql.user; mysql> exit; --退出mysql服务 [root@localhost ~]# vi /etc/my.cnf[mysqld] datadir=/var/lib/mysql socket=/var/lib/mysql/mysql.sock user=mysql default-character-set=utf8# Disabling symbolic-links is recommended to prevent assorted security riskssymbolic-links=0#设备地址bind-address=0.0.0.0 #设置设备地址[mysqld_safe]log-error=/var/log/mysqld.log pid-file=/var/run/mysqld/mysqld.pid
[root@localhost ~]# service mysqld start --重启mysql服务[root@localhost ~]# mysql -u root -p --连接mysql输入密码mysql> show global variables like 'port'; --查看端口号 +---------------+-------+ | Variable_name | Value | +---------------+-------+ | port | 3306 | +---------------+-------+ 1 row in set (0.00 sec)
以上是Linux下如何使用yum的方式安裝mysql的詳細內容。更多資訊請關注PHP中文網其他相關文章!