<img src="https://bucketblog.oss-cn-shenzhen.aliyuncs.com/blog/pic/mysql_logo.jpg" width="250" hegiht="150"/>mysql
yum -y install mysql-server
rpm -qa|grep mysql-server
default-character-set = utf8
character-set-server=utf8
sudo vim /etc/my.conf
default-character-set = utf8 character-set-server = utf8
chkconfig mysqld on
chkconfig --list mysqld
sudo vim /etc/sysconfig/iptables
-A INPUT -p tcp -m tcp --dport 3306 -j ACCEPT
sudo service iptables restart
sudo service mysqld start
或者sql
/etc/rc.d/init.d/mysqld start
由於 mysql 還未設置密碼,因此須要設置登陸數據庫服務器的密碼。shell
mysql -u root
select user,host from mysql.user;
delete from mysql.user where user='';
select user,host from mysql.user;
insert into mysql.user(Host, User, Password) values("localhost", "huaiangg", Password("123456"));
create database `mmall` default character set utf8 collate utf8_general_ci;
select * from mysql.user \G;
-- on 後面接的是 數據庫名.表名 .*表示該數據庫下的全部表 -- root@localhost 表示用戶名@ip地址 -- identitified by '123456' ''裏面表示該帳戶的密碼 -- with grant option 表示能夠把本身的權限賦值給別的用戶 grant all privileges on mmall.* to root@'%' identified by '123456' with grant option;
-- root@localhost ->> 用戶名@ip -- Password() ->> 內置函數 set password for root@localhost=Password('123456');
mysql -u root -p
ifconfig
select user,host,password from mysql.user;
set password for root@localhost=password('your new password');
或者數據庫
set password for root@127.0.0.1=password('your new password');
exit
mysql -u root -p
select user,host from mysql.user;
delect from mysql.user where user = '';
flush privileges;
insert into mysql.user(Host,User,Password) values("localhost", "yourusername", password("yourpaddword"));
flush privileges;
CREATE DATABASE `db_test` DEFAULT CHARRACTER SET utf8 COLLATE utf8_general_ci;
grant all privileges on db_test.* to yourusername@localhost identified by 'yourpassword';
grant all privileges on db_test.* to 'yourusername'@'%' identified by 'yourpassword';
grant select,insert,update on db_test.* to yourusername@'192.168.199.111' identified by 'yourpassword';
人若無名,專心練劍! 喜歡的朋友能夠留下你的贊!vim