程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 數據庫知識 >> MYSQL數據庫 >> 關於MYSQL數據庫 >> linux下默認安裝mysql數據庫

linux下默認安裝mysql數據庫

編輯:關於MYSQL數據庫
一.修改/etc/my.cnf文件default-character-set=utf8[mysqld]datadir= ar b/mysqlsocket= ar b/mysql/mysql.sockuser=mysql# Default to using old passWord format for compatibility with MySQL 3.x
# clients (those using the mysqlclIEnt10 compatibility package).old_passWords=1default-character-set=utf8 增加[mysqld_safe]log-error= ar/log/mysqld.logpid-file= ar/run/mysqld/mysqld.pid[mysql] 增加default-character-set=utf8 增加二.啟動Mysql並設置隋系統啟動chkconfig mysqld onchkconfig --list mysqld(查看系統服務)mysqld          0:off   1:off   2:on    3:on    4:on    5:on    6:off2-5為on,OK。/etc/rc.d/init.d/mysqld start三.設置密碼 /usr/bin/MySQLadmin -u root passWord '123456'四.測試
1.應用密碼為空測試:
MySQL -u rootERROR 1045 (28000): Access denIEd for user 'root'@'localhost' (using passWord: NO)
2.輸入密碼測試:
MySQL -u root -p
Enter passWord:Welcome to the MySQL monitor.  Commands end with ; or \g.Your MySQL connection id is 7Server version: 5.0.77 Source distMySQL> ribution
MySQL>
五.刪除匿名用戶
1.查看用戶,host,密碼列表方法
select user,host,passWord from MySQL.user;
2.刪除匿名用戶
 select user,host from MySQL.user 查看用戶信息
delete from MySQL.user where user=""; 刪除匿名用戶
六.刪除測試用數據庫
1.show databases; 查看系統已經存在的數據庫
2.drop database test;
七.對MySQL進行測試
1. grant all privileges on test.* to centospub@localhost identifIEd by '123456'; 建立對test數據庫有完全操作權的名為centosput的用戶
2.select user from MySQL.user 查看用戶存在與否
    -> ;+-----------+| user      |+-----------+| root      || centospub || root      || root      |+-----------+
3.退出,並以centospub登錄MySQL服務器
exit
mysql -u centospub -pEnter passWord:Welcome to the MySQL monitor.  Commands end with ; or \g.Your MySQL connection id is 12Server version: 5.0.77 Source distributionType 'help;' or '\h' for help. Type '\c' to clear the buffer.
4.建立test數據庫 create database test;
5.show databases;查看
6.use test; 鏈接到數據庫(Database changed)
7.create table test(num int,name varchar(50));建立表
8.show tables; 查看數據庫中存在的表
9.insert into test valuse(1,'Hello World');插入新值
10.查看插入新值
select * from test    -> ;+------+--------------+| num  | name         |+------+--------------+|    1 | Hello World! |+------+--------------+
11.update test set name='Hello Everyone!'; 更新表信息
12.再次查看
MySQL> select * from test    -> ;+------+-----------------+| num  | name            |+------+-----------------+|    1 | Hello Everyone! |+------+-----------------+1 row in set (0.00 sec)
13.delete from test;刪除值
14.drop table test;刪除test表
15.show tables;查看表,確認
16.drop database test;刪除test數據庫
17.show databases;查看庫,確認
八.刪除測試用過的用戶
1.應用root登錄MySQL數據庫
2.revoke all privileges on *.* from centospub@localhost; 取消centospub用戶對數據庫的操作權限
3.delete from MySQL.user where user='centospub' and host='localhost';刪除
4.select user from MySQL.user;查看,確認
5.flush privileges;刷新,使生效
九.重新啟動http服務
/etc/rc.d/init.d tpd restart
  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved