ubuntu安装mysql后的配置
2013-10-25 15:09
471 查看
1,备份 /etc/mysql/my.cnf
sudo cp /etc/mysql/my.cnf /etc/mysql/my.cnf.bak
2.编辑my.cnf
sudo vi /etc/mysql/my.cnf
大约47行
#bind-address = 127.0.0.1
加#注释掉 否则不能远程登录
[mysqld]里添加一行
character_set-server=utf8 (这里特别注意,老版本的是设置 default-character-set=utf8 然后服务无法启动)
设置mysql默认编码方式,默认的latin1不支持中文
这两项改完后 sudo /etc/init.d/mysql restart 重启服务,登录mysql 通过 status查看编码是否修改成功。
3.取消开机启动
由于不是每次开机都需要用到mysql,服务自启动浪费资源,改为手动管理mysql服务。
[sql]view plaincopyzhh@itant:/etc/init.d$ sudo service mysql stop
mysql stop/waiting
zhh@itant:/etc/init.d$ sudo update-rc.d -f mysql remove
Removing any system startup links for /etc/init.d/mysql ...
zhh@itant:/etc/init.d$ sudo service mysql start
mysql start/running, process 5186
zhh@itant:/etc/init.d$ mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands endwith ; or \g.
Your MySQL connection id is 36
Server version: 5.5.29-0ubuntu0.12.04.2 (Ubuntu)
Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;'or'\h'for help. Type '\c'to clear the current input statement.
mysql> exit
Bye
zhh@itant:/etc/init.d$
4.安装python-mysql
下载mysql-python 进入mysql-python目录,python install.py install 安装
提示 mysql_config not found,执行 sudo apt-get install libmysqld-dev 然后 sudo find / -name mysql_config 将查到的路径 编辑到 site.cfg中。
提示 _mysql.c:29:20: 致命错误: Python.h:没有那个文件或目录 ,执行 sudo apt-get install python-dev
最后执行安装命令
sudo python setup.py build
sudo python setup.py install
测试: python->import MySQLdb
sudo cp /etc/mysql/my.cnf /etc/mysql/my.cnf.bak
2.编辑my.cnf
sudo vi /etc/mysql/my.cnf
大约47行
#bind-address = 127.0.0.1
加#注释掉 否则不能远程登录
[mysqld]里添加一行
character_set-server=utf8 (这里特别注意,老版本的是设置 default-character-set=utf8 然后服务无法启动)
设置mysql默认编码方式,默认的latin1不支持中文
这两项改完后 sudo /etc/init.d/mysql restart 重启服务,登录mysql 通过 status查看编码是否修改成功。
3.取消开机启动
由于不是每次开机都需要用到mysql,服务自启动浪费资源,改为手动管理mysql服务。
[sql]view plaincopyzhh@itant:/etc/init.d$ sudo service mysql stop
mysql stop/waiting
zhh@itant:/etc/init.d$ sudo update-rc.d -f mysql remove
Removing any system startup links for /etc/init.d/mysql ...
zhh@itant:/etc/init.d$ sudo service mysql start
mysql start/running, process 5186
zhh@itant:/etc/init.d$ mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands endwith ; or \g.
Your MySQL connection id is 36
Server version: 5.5.29-0ubuntu0.12.04.2 (Ubuntu)
Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;'or'\h'for help. Type '\c'to clear the current input statement.
mysql> exit
Bye
zhh@itant:/etc/init.d$
4.安装python-mysql
下载mysql-python 进入mysql-python目录,python install.py install 安装
提示 mysql_config not found,执行 sudo apt-get install libmysqld-dev 然后 sudo find / -name mysql_config 将查到的路径 编辑到 site.cfg中。
提示 _mysql.c:29:20: 致命错误: Python.h:没有那个文件或目录 ,执行 sudo apt-get install python-dev
最后执行安装命令
sudo python setup.py build
sudo python setup.py install
测试: python->import MySQLdb
相关文章推荐
- mysql系统函数3----日期时间函数
- mysql系统函数4----转换函数
- mysql系统函数2----数学函数
- C# mysql 插入数据,中文乱码的解决方法
- mysql系统函数1----字符串函数
- innodb_file_per_table参数
- MySql 日期函数比较
- [MySQL 5.6] MySQL 5.6 online ddl 使用、测试及关键函数栈
- mysql给数据加密的函数password()是不可逆的
- 在utf8规则下 mysql varchar(50)能存50个汉字
- mysql的hex()和unhex()函数
- mysql聚合函数
- MySQL安装配置汇总(一)
- 解决安装MySQL5.1出现Cannot create windows service for mysql.error:0
- [转]MySQL导入.sql文件及常用命令
- mysql外连接不支持ON解决方法
- MySQL 定时器EVENT学习
- 安装、重装MySQL时,出现could not start the service mysql error:0的解决办法
- MySQL GRANT REVOKE用法
- mysql的几个简单实用技巧