linux安装MySQL

                                 linux安装MySQL

1:下载MySQL:get http://dev.mysql.com/get/Downloads/MySQL-5.6/mysql-5.6.33-linux-glibc2.5-x86_64.tar.gz

我的下载文件夹为: /usr/local/mysql

2:解压到你要安装的文件夹:tar -zxvf mysql.gz -C /usr/local/mysql/mysql

3:安装

4:创建一个mysql用户和组

命令:groupadd mysql

useradd -r -g mysql -s /bin/false mysql

5:更改mysql目录下所有的目录及文件夹所属组合用户

 

cd /usr/local/mysql

 

chown -R mysql mysql/

chgrp -R mysql mysql/

6安装链接库文件:

yum install  libaio-devel.x86_64

7:安装和初始化数据库 

进入mysql的bin文件夹下。

mysqld --initialize --user=mysql --basedir=/usr/local/mysql/mysql --datadir=/usr/local/mysql/mysql/data

最后会生成一个初始的随机化的密码。记住他。以后改密码的时候会用。

密码是localhost:后面的字符串。

8:执行bin/mysql_ssl_rsa_setup  --datadir=/usr/local/mysql/mysql/data

9:复制my-default.cnf到系统配置里 cp my-default.cnf /etc/my.cnf

10:修改这个配置文件如下内容

#dvice on how to change settings please see
# http://dev.mysql.com/doc/refman/5.7/en/server-configuration-defaults.html
# *** DO NOT EDIT THIS FILE. It's a template which will be copied to the
# *** default location during install, and will be replaced if you
# *** upgrade to a newer version of MySQL.
 
[mysqld]
 
 
 
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES 
 
# 一般配置选项
basedir = /usr/mysql
datadir = /usr/mysql/data
port = 3306
#socket = /temp/mysqld.sock
socket = /var/run/mysqld/mysqld.sock
character-set-server=utf8
 
 
#下面是可选项,要不要都行,如果出现启动错误,则全部注释掉,保留最基本的配置选项,然后尝试添加某些配置项后启动,检测配置项是否有误
back_log = 300
max_connections = 3000
max_connect_errors = 50
table_open_cache = 4096
max_allowed_packet = 32M
#binlog_cache_size = 4M
 
max_heap_table_size = 128M
read_rnd_buffer_size = 16M
sort_buffer_size = 16M
join_buffer_size = 16M
thread_cache_size = 16
query_cache_size = 128M
query_cache_limit = 4M
ft_min_word_len = 8
 
thread_stack = 512K
transaction_isolation = REPEATABLE-READ
tmp_table_size = 128M
#log-bin=mysql-bin
long_query_time = 6
 
 
server_id=1
 
innodb_buffer_pool_size = 1G
innodb_thread_concurrency = 16
innodb_log_buffer_size = 16M
 
 
innodb_log_file_size = 512M
innodb_log_files_in_group = 3
innodb_max_dirty_pages_pct = 90
innodb_lock_wait_timeout = 120
innodb_file_per_table = on
 
[mysqldump]
quick
 
max_allowed_packet = 32M
 
[mysql]
no-auto-rehash
socket = /var/run/mysqld/mysqld.sock
default-character-set=utf8
safe-updates
 
 
[myisamchk]
key_buffer = 16M
sort_buffer_size = 16M
read_buffer = 8M
write_buffer = 8M
 
[mysqlhotcopy]
interactive-timeout
 
[mysqld_safe]
open-files-limit = 8192
 
[client]
loose-default-character-set = utf8

11:实现在任意路径利用server mysql stop(start)启动或者停止mysql :cp mysql.server /etc/init.d/mysqld

12:登陆MySQL:./mysql -uroot -p这时候需要用到最开始的密码

13:修改root密码:SET PASSWORD = PASSWORD('root');

 

14:设置远程连接:update user set host = '%' where user = 'root';

15:关闭mysql

16重启mysql:

/etc/init.d/mysqld restart或者server mysql restart

17:然后可以在sqlyog或者axure测试远程连接

如果失败的话一般是没配置好路径。在vim /etc/init.d/mysqld和mysql下的conf下的server配置环境有问题下修改文件配置。

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值