mysql笔记

阅读更多

查询mysql版本:

 

mysql> select @@version

 

 

安装mysql数据库:

 

$ wget http://dev.mysql.com/get/mysql-community-release-el7-5.noarch.rpm
$ yum localinstall mysql-community-release-el7-5.noarch.rpm 
$ yum install mysql-community-server
$ systemctl start mysql
$ mysql_secure_installation

 

 

    1、打开./etc/my.cnf文件

    2、在【mysqld】下添加:character-set-server=utf8,此处为修改服务端的编码为utf8

    3、在【client】下添加:default-character-set=utf8,此处为修改客户端的编码为utf8

    4、重启mysql,查看mysql编码:

 

mysql>show variables like 'character%';

 

 

使用mysql的命令修改mysql默认字符集的方法:

 

mysql> SET character_set_client = utf8 ;  
mysql> SET character_set_connection = utf8 ;   
mysql> SET character_set_database = utf8 ;   
mysql> SET character_set_results = utf8 ;    
mysql> SET character_set_server = utf8 ;   
mysql> SET collation_connection = utf8 ;  
mysql> SET collation_database = utf8 ;   
mysql> SET collation_server = utf8 ; 

 

 

修改数据库字符集:

 

mysql> alter database petinn character set utf8;

 

 

显示数据库字符集:

 

mysql> show create database dbname;

 

 

创建数据库:

 

CREATE DATABASE XXXXXX DEFAULT CHARACTER SET utf8;

 

重启mysql数据库:

$ service mysqld restart

 

 

卸载mysql:

$ yum remove mysql mysql-server mysql-libs mysql-server;

   查找mysql安装的相关目录,然后删除

$ find / -name mysql

   

$ rpm -qa|grep mysql

 

你可能感兴趣的:(mysql笔记)