Centos6.5使用yum安裝mysql——快速上手必備

第1步、yum安裝mysql

[root@stonex ~]#  yum -y install mysql-server

安裝結果:

Installed:

    mysql-server.x86_64 0:5.1.73-3.el6_5                                                                                                                                                         

Dependency Installed:

    mysql.x86_64 0:5.1.73-3.el6_5

    perl-DBD-MySQL.x86_64 0:4.013-3.el6                                

    perl-DBI.x86_64 0:1.609-4.el6


第2步、設置開機啓動

[root@stonex ~]#  chkconfig mysqld on


第3步、啓動MySql服務

[root@stonex ~]#  service mysqld start


第4步、設置MySQL的root用戶設置密碼

[root@stonex ~]#  mysql -u root

Welcome to the MySQL monitor.  Commands end with ; or \g.

...... 省略了一些行

mysql> select user,host,password from mysql.user;

查詢用戶的密碼,都爲空,用下面的命令設置root的密碼爲root

mysql> set password for root@localhost=password('root');

mysql> exit


第5步、用新密碼登陸

[root@stonex ~]#  mysql -u root -p


第6步、基本命令

show databases; //查看系統已存在的數據庫

use databasesname;   //選擇需要使用的數據庫

drop database databasename; //刪除選定的數據庫

exit    //退出數據庫的連接

create database test01;    //建立名爲test的數據庫

show tables;        // 列出當前數據庫下的表

其他基本的增刪改查使用標準SQL即可


第7步、開放遠程登錄權限

GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'root' WITH GRANT OPTION;

FLUSH PRIVILEGES;


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章