LIULIANG

ubuntu 11.10 server 安装mysql-5.5.22-linux2.6-i686.tar.gz

下载地址:
http://dev.mysql.com/downloads/mysql/


1、添加用户组
#> groupadd mysql
2、添加用户
#> useradd -r -g mysql mysql
3、切换目录
#> cd /usr/local
4、解压(mysql-5.5.22-linux2.6-i686.tar.gz已经复制到/usr/local下)
#> tar zxvf mysql-5.5.22-linux2.6-i686.tar.gz
5、创建软链接
#> ln -s mysql-5.5.22-linux2.6-i686 mysql
6、删除压缩包(可操作)
#> rm mysql-5.5.22-linux2.6-i686.tar.gz
7、进入mysql目录
#> cd mysql
8、改变用户权限和组权限
#> chown -R mysql .
#> chgrp -R mysql .

9、初始化数据库
<1> 保证在/etc/目录下面没有my.cnf、mysql文件夹,如果有请删除
<2> 安装libaio1.so 执行sudo apt-get install libaio1 安装了则跳过
#> scripts/mysql_install_db --user=mysql


初始化成功则出现如下提示:
Installing MySQL system tables...
OK
Filling help tables...
OK


To start mysqld at boot time you have to copy
support-files/mysql.server to the right place for your system


PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To do so, start the server, then issue the following commands:


./bin/mysqladmin -u root password 'root'
./bin/mysqladmin -u root -h VWmare password 'new-password'


Alternatively you can run:
./bin/mysql_secure_installation


which will also give you the option of removing the test
databases and anonymous user created by default.  This is
strongly recommended for production servers.


See the manual for more instructions.


You can start the MySQL daemon with:
cd . ; ./bin/mysqld_safe &


You can test the MySQL daemon with mysql-test-run.pl
cd ./mysql-test ; perl mysql-test-run.pl


Please report any problems with the ./bin/mysqlbug script!



10、修改权限
#> chown -R root .
#> chown -R mysql data



11、复制配置文件
#> cp support-files/my-medium.cnf /etc/my.cnf
#> cp support-files/mysql.server /etc/init.d/mysql.server



12、启动数据库
#> bin/mysqld_safe --user=mysql &


13、查看是否有3306端口启动
#> netstat -nat


14、设置密码
#> ./bin/mysqladmin -u root password 'new-password'
或者
#> ./bin/mysql_secure_installation


15、使用mysql
#> cd bin  
#> ./mysql -u root -p



16、设置开机自动启动
#> cd /etc/init.d/
sudo update-rc.d mysql.server defaults


17、设置默认编码为UTF8

登录MySQL,执行编码显示:

show variables like 'character%';

QUOTE:

+--------------------------+----------------------------+
| Variable_name | Value |
+--------------------------+----------------------------+
| character_set_client | latin1 |
| character_set_connection | latin1 |
| character_set_database | latin1 |
| character_set_filesystem | binary |
| character_set_results | latin1 |
| character_set_server | latin1 |
| character_set_system | utf8 |
| character_sets_dir | /usr/share/mysql/charsets/ |
+--------------------------+----------------------------+


sudo vi /etc/mysql/my.cnf


找到[client] 添加:



default-character-set=utf8

找到[mysqld] 添加:


default-character-set=utf8

init_connect='SET NAMES utf8'


sudo/etc/init.d/mysql.server restart

修改好后,重新启动mysql 即可.


若启动异常则把[mysqld]处修改为

character_set_server = utf8

init_connect='SET NAMES utf8'


查询一下show variables like 'character%';

QUOTE:

+--------------------------+----------------------------+
| Variable_name | Value |
+--------------------------+----------------------------+
| character_set_client | utf8 |
| character_set_connection | utf8 |
| character_set_database | utf8 |
| character_set_filesystem | binary |
| character_set_results | utf8 |
| character_set_server | utf8 |
| character_set_system | utf8 |
| character_sets_dir | /usr/share/mysql/charsets/ |
+--------------------------+----------------------------+


转自:http://blog.csdn.net/lmyclever/article/details/7421716

posted on 2012-09-14 10:52 BIG森林 阅读(2003) 评论(0)  编辑 收藏 引用 所属分类: Ubuntu


只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理


<2024年11月>
272829303112
3456789
10111213141516
17181920212223
24252627282930
1234567

导航

统计

常用链接

留言簿(2)

随笔分类

随笔档案

搜索

最新评论

阅读排行榜

评论排行榜