linux mysql-5.6.26 安装
下载地址
ftp://mirror.switch.ch/mirror/mysql/Downloads/MySQL-5.6/mysql-5.6.26-linux-glibc2.5-x86_64.tar.gz
解压
tar -xzf mysql-5.6.26-linux-glibc2.5-x86_64.tar.gz
注:安装目录需要设置到解压目录,否则报以下错误
FATAL ERROR: Could not find ./bin/my_print_defaults If you compiled from source, you need to run 'make install' to copy the software into the correct location ready for operation. If you are using a binary release, you must either be at the top level of the extracted archive, or pass the --basedir option pointing to that location.
or
FATAL ERROR: Could not find my-default.cnf If you compiled from source, you need to run 'make install' to copy the software into the correct location ready for operation. If you are using a binary release, you must either be at the top level of the extracted archive, or pass the --basedir option pointing to that location.
将解压的目录放到/usr/local下改为mysql或添加软连接
mv mysql-5.6.26-linux-glibc2.5-x86_64 mysql
or
ln -s /www/mysql-5.6.26-linux-glibc2.5-x86_64 /usr/local/mysql
增加mysql用户和组
groupadd mysql
useradd -r -g mysql mysql
修改mysql目录及子文件属主和属组
chown -R mysql:mysql mysql
进入mysql目录并安装
cd mysql
scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql --datadir=/var/lib/mysql
安装过程可能缺少某些文件,一般用 yum install -y xxx 按需安装即可.
实现使用 service mysqll (start|status|stop) 命令操作mysql.
cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysql
错误:
[root@localhost mysql]# mysql
-bash: mysql: command not found
解决:配置环境变量,把 export PATH=$PATH:/usr/local/mysql/bin添加到 /etc/profile中, source /etc/profile重新加载环境变量, service mysql start启动mysql服务。
错误:
[root@localhost mysql]# mysql ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
解决:
mysql --socket=/var/lib/mysql/mysql.sock ln -s /var/lib/mysql/mysql.sock /tmp/mysql.sock
启动成功
mysql> select version(); +-----------+ | version() | +-----------+ | 5.6.26 | +-----------+ 1 row in set (0.00 sec)
成功后可能需要往mysql的user表增加新账号
错误:指定了严格模式,为了安全,严格模式禁止通过insert 这种形式直接修改mysql库中的user表进行添加新用户
1364 - Field 'ssl_cipher' doesn't have a default value
解决:
vim /usr/local/mysql/my.cnf
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
改为
sql_mode=NO_ENGINE_SUBSTITUTION
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· AI与.NET技术实操系列:基于图像分类模型对图像进行分类
· go语言实现终端里的倒计时
· 如何编写易于单元测试的代码
· 10年+ .NET Coder 心语,封装的思维:从隐藏、稳定开始理解其本质意义
· .NET Core 中如何实现缓存的预热?
· 25岁的心里话
· 闲置电脑爆改个人服务器(超详细) #公网映射 #Vmware虚拟网络编辑器
· 零经验选手,Compose 一天开发一款小游戏!
· 因为Apifox不支持离线,我果断选择了Apipost!
· 通过 API 将Deepseek响应流式内容输出到前端