💎一站式轻松地调用各大LLM模型接口,支持GPT4、智谱、星火、月之暗面及文生图 广告
[TOC] ## 1. 5.6 一、apt-get安装及配置 1.前提 > 此安装方法的前提是,链接互联网 2.安装mysql > 更新源 sudo apt-get update * 安装MySQL-client-core-5.6 ~~~ sudo apt-get install MySQL-client-core-5.6 ~~~ * 安装mysql-client-5.6 sudo apt-get install mysql-client-5.6 * 安装mysql-server-5.6 ~~~ sudo apt-get install mysql-server-5.6 ~~~ 3.检查mysql状态 > 执行完成上面的命令之后,正常情况mysql服务会自启动 > 检查mysql的启动状态 * 查看进程 ~~~ ps -ef | grep mysql ~~~ * 查看端口监听 ~~~ netstat -tap | grep mysql ~~~ * 链接mysql进行状态检查 ~~~ mysql -h localhost -u root -p Enter password: mysql> status; -------------- mysql Ver 14.14 Distrib 5.6.33, for debian-linux-gnu (x86_64) using EditLine wrapper Connection id: 37 Current database: Current user: root@localhost SSL: Not in use Current pager: stdout Using outfile: '' Using delimiter: ; Server version: 5.6.33-0ubuntu0.14.04.1 (Ubuntu) Protocol version: 10 Connection: Localhost via UNIX socket Server characterset: latin1 Db characterset: latin1 Client characterset: utf8 Conn. characterset: utf8 UNIX socket: /var/run/mysqld/mysqld.sock Uptime: 25 min 27 sec Threads: 1 Questions: 115 Slow queries: 0 Opens: 87 Flush tables: 1 Open tables: 80 Queries per second avg: 0.075 -------------- ~~~ 4.修改必要的配置 ~~~ sudo vim /etc/mysql/my.cnf ~~~ * 修改远程访问 > 为了可以远程访问,将[mysqld]下面的这行注释掉 > Instead of skip-networking the default is now to listen only on > localhost which is more compatible and is not less secure. > bind-address = 127.0.0.1 * 修改字符编码,在client,mysqld,mysql配置段,分别追加如下编码信息 ~~~ [client] default-character-set = utf8 [mysqld] character-set-server=utf8 lower_case_table_names = 1 # 忽略查询大小写 [mysql] default-character-set=utf8 ~~~ 再次查看status,变为utf8编码 ~~~ Server characterset: utf8 Db characterset: utf8 Client characterset: utf8 Conn. characterset: utf8 ~~~ * 新建数据库和用户 ~~~ create database `devicedb` default character set utf8 collate utf8_general_ci; CREATE USER 'device'@'%' IDENTIFIED BY '4rfv$RFV'; GRANT ALL ON devicedb.* TO 'device'@'%' IDENTIFIED BY '4rfv$RFV'; //只有执行了这一句才可以登陆 FLUSH PRIVILEGES; ~~~ 5.卸载旧版本 ~~~ #停止mysql的服务 sudo service mysql stop #删除mysql的数据文件(必要的情况下) sudo rm /var/lib/mysql/ -R #删除mqsql的配置文件 sudo rm /etc/mysql/ -R #删除mysql软件 sudo apt-get autoremove mysql* --purge ~~~ ## 2. Ubuntu 安装 安装server时会提示输入密码 ![](https://box.kancloud.cn/0c1585f31b6a58cd277ad77a6153d3be_1595x345.png) ~~~ sudo dpkg -i mysql-common_5.6.38-1ubuntu14.04_amd64.deb sudo dpkg -i libmysqlclient18_5.6.38-1ubuntu14.04_amd64.deb sudo dpkg -i libmysqlclient-dev_5.6.38-1ubuntu14.04_amd64.deb sudo dpkg -i libmysqld-dev_5.6.38-1ubuntu14.04_amd64.deb sudo dpkg -i mysql-community-client_5.6.38-1ubuntu14.04_amd64.deb sudo dpkg -i mysql-client_5.6.38-1ubuntu14.04_amd64.deb sudo dpkg -i mysql-community-server_5.6.38-1ubuntu14.04_amd64.deb ~~~ ### 5.7 安装 1. 安装 ~~~ tar -xvf ./mysql-server_5.7.23-1ubuntu14.04_amd64.deb-bundle.tar dpkg -i mysql-common_5.7.23-1ubuntu14.04_amd64.deb dpkg -i libmysqlclient20_5.7.23-1ubuntu14.04_amd64.deb dpkg -i libmysqlclient-dev_5.7.23-1ubuntu14.04_amd64.deb dpkg -i libmysqld-dev_5.7.23-1ubuntu14.04_amd64.deb dpkg -i mysql-community-client_5.7.23-1ubuntu14.04_amd64.deb dpkg -i mysql-client_5.7.23-1ubuntu14.04_amd64.deb dpkg -i mysql-community-server_5.7.23-1ubuntu14.04_amd64.deb # 会让输入密码 apt-get -y install libaio1 libmecab2 ~~~ 2. 修改配置 ``` service mysql stop mkdir -p /data/mysqldata chown mysql.mysql /data/mysqldata mkdir /var/log/mysql chown mysql.mysql /var/log/mysql ``` ``` vim /etc/my.cnf [client] port = 3306 socket = /data/mysqldata/mysqld.sock default-character-set = utf8 [mysqld_safe] socket =/data/mysqldata/mysqld.sock nice = 0 [mysqld] user = mysql pid-file = /data/mysqldata/mysqld.pid socket = /data/mysqldata/mysqld.sock port = 3306 basedir = /usr datadir = /data/mysqldata tmpdir = /tmp lc-messages-dir = /usr/share/mysql skip-external-locking #key_buffer = 16M max_allowed_packet = 16M thread_stack = 192K thread_cache_size = 8 #myisam-recover = BACKUP max_connections = 200 query_cache_limit = 1M query_cache_size = 16M log_error = /var/log/mysql/error.log expire_logs_days = 10 max_binlog_size = 100M character-set-server=utf8 server-id = 1 log_bin = /var/log/mysql/mysql-bin.log sync_binlog=1 binlog_format=mixed lower_case_table_names = 1 innodb_buffer_pool_size=1G [mysqldump] quick quote-names max_allowed_packet = 16M [mysql] default-character-set=utf8 [isamchk] # key_buffer = 16M ``` ``` mv /var/lib/mysql/* /data/mysqldata/ ./mysqld --initialize --datadir=/data/mysql/3306/data --user=mysql --basedir=/usr/local/mysql/ ```