ubuntu安装配置mysql

作者:fly 发布于:2015-1-11 12:22 分类:Linux

www.forwhat.cn

1.安装: apt-get install mysql-server

 

2.设置允许远程登录

 修改/etc/mysql/my.cnf(此文件为mysql的配置文件)。将文件中的binding-address=127.0.0.1注释掉。

 从本机登陆mysql:mysql -u root -p

 use mysql;

 设置允许所有主机连接到Mysql,执行命令:grant all privileges on *.* to root@"%" identified by "root用户的密码" with grant option;

 

3.重启mysql

 /etc/init.d/mysql restart

*注:/etc/init.d/mysql start|stop|restart可以启动/停止/重启

 

4.设置开机自启动

把启动命令(/etc/init.d/mysql start)加入/etc/rc.local文件中

 

5.设置Mysql字符集:

创建数据库时指定字符集:create database mydb character set utf-8;

查看当前字符集:show variables like 'character%';

修改当前数据库的字符集:

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 NAMES utf8; //这条语句会改变  character_set_client  character_connection   character_results这三个 的字符集

发表评论:

 
Powered by emlog sitemap