《RHEL6下mysql的搭建》

來源:互聯網
上載者:User

mysql ==========

yum install mysql mysql-server

mysqladmin -uroot -predhat password westos   修改本地mysql root密碼

mysqladmin -uroot -predhat -h 192.168.0.188 password westos 修改遠程192.168.0.188 mysql伺服器 root密碼  

mysql_secure_installation     第一次安裝mysql以後通過這條命令可以對mysql進行設定

mysql -uroot -predhat      從本機登入mysql資料庫

show databases;       顯示資料庫

use mysql;       進入資料庫

show tables;       顯示資料庫中的表

desc user;       查看user表的資料結構

flush privileges;      重新整理資料庫資訊

select host.user,password from user;    查詢user表中的host,user,password欄位

create database westos;      建立westos資料庫

use westos;        create table linux(      建立表,username,password欄位 username varchar(15) not null, password varchar(15) not null );

select * from mysql.user;     查詢mysql庫下的user表中的所以

show tables; desc linux;

insert into linux values ('user1','passwd1');    在linux表中插入值為username = user1,password = password1

update linux set password=password('passwd2') where username=user1; 更新linux表中user1 的密碼為password2

delete from linux where username='user1';     刪除linux表中user1的所以內容

grant select on  *.* to user1@localhost identified by 'passwd1'; 授權user1 密碼為passwd1  並且只能在本地 查詢資料庫的所以內容

grant all on mysql.* to user2@'%' identified by 'passwd2';  授權user2 密碼為passwd2  可以從遠程任意主機登入mysql 並且可以對mysql資料庫任意操作

備份 /var/lib/mysql mysqldump -uroot -predhat mysql > mysql.bak 備份mysql庫到mysql.bak

mysql -uroot -predhat westos < mysql.bak 恢複mysql.bak 到westos庫

 

mysql 密碼恢複 /etc/init.d/mysqld stop

mysqld_safe --skip-grant-tables &     跳過grant-tables授權表  不需要認證登入本地mysql資料庫

update mysql.user set Password=password('westos') where User='root'; 更新mysql.user 表中條件為root使用者的密碼為加密westos

/etc/init.d/mysql restart

 

phpmyadmin yum install php php-mysql httpd mysql mysql-server

tar jxf phpmyadmin-*.tar.bz2 -C /var/www/html mv phpmyadmin phpadmin cp config.sample.inc.php config.inc.php vim config.inc.php add $cfg['blowfish_secret'] = 'test';

/etc/init.d/httpd start http://192.168.0.188/phpadmin

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.