时间:2021-07-01 10:21:17 帮助过:33人阅读
下载地址: 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-li
下载地址:
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: |
+--------------------------+----------------------------+ |
找到[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: |
+--------------------------+----------------------------+ |