day1 mysql

Download mysql steps
1, we /etc/yum.repos.d/MariaDB.repo
2, add the repo warehouse configuration
[mariadb]
name = MariaDB
baseurl = http://yum.mariadb.org/10.1/centos7-amd64
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck=1
3,yum install MariaDB-server MariaDB-client -y
4, start mariadb related commands
systemctl start mariadb
5, mysql_secure_installation initialization
6, mysql -uroot -p into the database
mysql -u username -p format ---> access to the database
mysql -uroot -p
Behind each sql statement to; end
set password = PASSWORD ( 'new password'); the password may be changed
exit out of the database
Storehouse
show databases; see command database
create database c1908; create a database
use c1908; switch databases
table
create table cc(id int,name char(6));
show tables; see what the library table
desc cc; details see table
recording
insert into cc values(1,'egon1'),(2,'egon2'),(3,'egon3');
Insert Record
select * from cc; 看表
create user "student"@"%" identified by "123";
Create a user can log% on any machine
grant all privileges on c1908.* to student@"%";
Authorize
flush privileges;
刷新权限
退出MySQL,去修改配置文件,修改完重启MySQL,再登陆,之前建的库还是不识别中文的,重新创建的才识别。
mysql配置中文:
1.修改mysql的配置文件 /etc/my.cnf,写入以下中文配置信息
[mysqld]
character-set-server=utf8
collation-server=utf8_general_ci
log-error=/var/log/mysqld.log
[client]
default-character-set=utf8
[mysql]
default-character-set=utf8
2.修改完配置文件,需要重启mysql,使得生效
systemctl restart mariadb

Guess you like

Origin www.cnblogs.com/Darry-Ring/p/12143081.html