首页 / LINUX / linux安装mysql.
linux安装mysql.
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了linux安装mysql.,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含3741字,纯文字阅读大概需要6分钟。
内容图文
![linux安装mysql.](/upload/InfoBanner/zyjiaocheng/531/70f7645fd85445f58f2404acbc109139.jpg)
下载地址: 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、设置默认编码为UTF82>1>
登录MySQL,执行编码显示:
show variables like 'character%';
QUOTE: |
+--------------------------+----------------------------+ |
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: |
+--------------------------+----------------------------+ |
内容总结
以上是互联网集市为您收集整理的linux安装mysql.全部内容,希望文章能够帮你解决linux安装mysql.所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。