debian 6.0 安装mysql

1 篇文章 0 订阅

1、下载mysql安装包mysql-5.7.23-linux-glibc2.12-i686.tar    mysql官网:https://dev.mysql.com/downloads/mysql/5.7.html#downloads  选择通用linux,x86版本。
        相关的依赖库 libaio1_0.3.111-1_i386.deb  libnuma1_2.0.11-2.1_i386.deb  使用dpkg -i  *.deb安装包名
2、添加mysql组和mysql用户,用于设置mysql安装目录文件所有者和所属组。
    groupadd mysql 
    useradd -r -g mysql mysql
3、cd /usr/local
        mkdir mysql  //创建mysql目录
        chown -R mysql 
        chgrp -R mysql 
4、通过FTP安装文件上传到/usr/local/mysql目录,解压安装包
         tar -zxvf  mysql-5.7.23-linux-glibc2.12-i686.tar
        dpkg -i  libaio1_0.3.111-1_i386.deb
        dpkg -i  libnuma1_2.0.11-2.1_i386.deb 
5、在mysql目录下创建mysql_data和mysql-files
        mkdir mysql_data
        mkdir mysql-files
        并将mysql的目录给予充分权限
        chmod 777 -R /usr/local/mysql
6、mysql进行初始化工作,注意baserdir和datadir的地址实际创建的文件夹地址保持一致
      bin/mysqld --initialize --user=mysql --basedir=/usr/local/mysql/mysql --datadir=datadir = /usr/local/mysql/mysql_data
      
7.添加环境变量,将mysql/bin目录添加到环境变量/etc/init.d/rc.local文件内
    export PATH=$PATH:/usr/local/mysql/mysql/bin
8、将mysql/bin目录下的mysqld复制到/etc/init.d/目录并给予可执行权限
    cp mysql/bin/mysqld  /etc/init.d/
    chmod 777 /etc/init.d/mysqld
9、将mysql配置文件my.cn复制到/etc目录
  cp my.cnf   /etc/
  chmod 777 /etc/my.cnf
10、启动mysql
    service mysqld start 
11、连接mysql 使用 在本机终端使用mysql -u root -p  连接到数据库
如果遇到mysql密码不知道先停止mysql服务,service  mysqld stop 
然后使用以下方式登录数据库重置密码
 mysqld_safe --user=mysql --skip-grant-tables --skip-networking &   
启动后以下方式可以直接免密码登录数据库
mysql -u root mysql 

mysql> UPDATE user SET authentication_string=PASSWORD('123456') where USER='root';   //将使用root用户登录的密码设置为123456
mysql> FLUSH PRIVILEGES;
mysql> quit
然后停止mysqld_safe --user=mysql --skip-grant-tables --skip-networking &   启动的进程使用service  mysqld start 开启数据库
使用mysql -uroot -p可以重新连接数据,新密码就是上一步设置的123456
Enter password: <输入新设的密码newpassword>
在其他终端就可以使用NaVicat等数据库终端直接连接数据了。

12、 使用 insserv  /etc/init.d/mysqld 就可以将mysql加入到开机自启动服务里了

 

如果出现在本地使用libmysqlclient.so库的mysql_real_connect(&mysql,"127.0.0.1","root","123456","mysql",3306,NULL,0)的函数连接失败,而可以远程连接,在my.cnf的[mysqld]部分添加bind-address = 127.0.0.1,就可以连接了。

# For advice on how to change settings please see
# http://dev.mysql.com/doc/refman/5.6/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.

[client]

port = 3306
socket = /usr/local/mysql/mysql_data/mysql.sock

[mysqld]

# Remove leading # and set to the amount of RAM for the most important data
# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.
# innodb_buffer_pool_size = 128M

# Remove leading # to turn on a very important data integrity option: logging
# changes to the binary log between backups.
# log_bin

# These are commonly set, remove the # and set as required.
# basedir = .....
# datadir = .....
# port = .....
# server_id = .....
# socket = .....

skip_host_cache
skip-name-resolve=1

basedir = /usr/local/mysql/mysql
datadir = /usr/local/mysql/mysql_data
#bind-address = 127.0.0.1
port = 3306
server_id = 1
socket = /usr/local/mysql/mysql_data/mysql.sock

log-bin = /usr/local/mysql/mysql-files/mysqld.log
expire_logs_days = 10
max_binlog_size = 100M

#general_log = 1
#general_log_file = /usr/local/lnmp/mysql-5.7/query.log


slow_query_log = 1
slow_query_log_file = /usr/local/mysql/mysql-files/slow-query.log
long-query_time = 2

log-error = /usr/local/mysql/mysql-files/error.log

# Remove leading # to set options mainly useful for reporting servers.
# The server defaults are faster for transactions and fast SELECTs.
# Adjust sizes as needed, experiment to find the optimal values.
# join_buffer_size = 128M
# sort_buffer_size = 2M
# read_rnd_buffer_size = 2M 

#sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES 

    

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值