• linux安装MySql


    MySql编译版安装(版本5.6.13)**************************************************************************************************************************************************************************************************************************

    下载MySql(5.6.13),注意这里只针对MySql5.6.13

    到oracle去下载
    或在这里下载(我共享的百度云盘的文件):http://27.155.72.130/d7.baidupcs.com/file/4bfeb22f2f876825db70d9820d164343?bkt=p3-14004bfeb22f2f876825db70d9820d164343a6bde64f000002249238&xcode=c8445448be82a994c0fedf6bff69a325fc48c3c89a397b4b1682cb8519c2059f&fid=1684424001-250528-53404473674615&time=1480915931&sign=FDTAXGERLBH-DCb740ccc5511e5e8fedcff06b081203-WNytNOmBWfMPX6Qaqi8dzNQ3xYk%3D&to=d7&fm=Nin,B,T,t&sta_dx=35951160&sta_cs=1854&sta_ft=gz&sta_ct=0&sta_mt=0&fm2=Ningbo,B,T,t&newver=1&newfm=1&secfm=1&flow_ver=3&pkey=14004bfeb22f2f876825db70d9820d164343a6bde64f000002249238&sl=79036494&expires=8h&rt=sh&r=310023027&mlogid=7875448359956317706&vuk=1684424001&vbdid=1029378553&fin=mysql-5.6.13.tar.gz&fn=mysql-5.6.13.tar.gz&slt=pm&uta=0&rtype=1&iv=0&isw=0&dp-logid=7875448359956317706&dp-callid=0.1.1&csl=105&csign=a55iXbfzi23yAiPbzlK%2FEqzk8XQ%3D&wshc_tag=0&wsts_tag=5844fbdb&wsid_tag=79232df0&wsiphost=ipdbm

    mkdir /D/programfiles/MySql -p # 创建待安装MySql目录

    groupadd mysql # 添加mysql用户组
    useradd -s /sbin/nologin -g mysql mysql # 在mysql用户组中添加mysql用户(mysql不允许登录)

    yum install cmake # 安装编译工具
    yum install bison # Yacc-like分析器生成器(生成解释器,编译器,协议实现工具)
    yum install gcc gcc-c++ # 安装c++编译器
    yum install ncurses-devel # 字符处理等级库

    解压MySql压缩包

    tar -zxvf mysql-5.6.13.tar.gz -C /D/programfiles

    进入目录

    cd /D/programfiles/mysql-5.6.13

    cmake设置安装参数(在设置之前需进入解压后的mysql-5.6.13目录,利用CMAKE_INSTALL_PREFIX制定MySql安装目录)

    cmake -DCMAKE_INSTALL_PREFIX=/D/programfiles/MySql -DMYSQL_UNIX_ADDR=/D/programfiles/MySql/mysql.sock -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DWITH_EXTRA_CHARSETS:STRING=utf8,gbk -DWITH_MYISAM_STORAGE_ENGINE=1 -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_READLINE=1 -DENABLED_LOCAL_INFILE=1 -DMYSQL_DATADIR=/D/programfiles/MySql/data

    -DCMAKE_INSTALL_PREFIX # 安装目录
    -DMYSQL_UNIX_ADDR # 连接数据库socket路径
    -DDEFAULT_CHARSET # 默认编码
    -DINSTALL_DATADIR # 数据库存放目录
    -DDEFAULT_COLLATION # 校验字符
    -DWITH_EXTRA_CHARSETS:STRING # 扩展字符集
    -DWITH_MYISAM_STORAGE_ENGINE # 支持MyIASM引擎
    -DWITH_INNOBASE_STORAGE_ENGINE # 支持InnoDB引擎
    -DWITH_READLINE # 快捷键功能
    -DENABLED_LOCAL_INFILE # 是否允许从本地导入数据
    -DMYSQL_DATADIR # 数据文件存放位置

    开始make(make时比较慢估计10分钟)

    make
    make install

    初始化MySql

    /D/programfiles/MySql/scripts/mysql_install_db --user=mysql --basedir=/D/programfiles/MySql --datadir=/D/programfiles/MySql/data
    或(5.7几的版本)
    /D/programfiles/MySql/bin/mysqld --initialize --datadir=/D/programfiles/MySql/data --user=mysql --basedir=/D/programfiles/MySql

    创建日志目录

    mkdir /D/programfiles/MySql/logs -p

    /D/programfiles/MySql/bin/mysqld_safe --user=mysql

    设置环境变量

    ln -s /D/programfiles/MySql/my.cnf /etc/my.cnf
    ln -s /D/programfiles/MySql/lib /usr/lib/mysql
    ln -s /D/programfiles/MySql/include /usr/include/mysql
    ln -s /D/programfiles/MySql/bin/mysql /usr/bin/mysql
    ln -s /D/programfiles/MySql/bin/mysqldump /usr/bin/mysqldump
    ln -s /D/programfiles/MySql/bin/myisamchk /usr/bin/myisamchk
    ln -s /D/programfiles/MySql/lib/libmysqlclient.so.18 /usr/lib/libmysqlclient.so.18

    设置权限

    chmod +w /D/programfiles/MySql
    chown -R mysql:mysql /D/programfiles/MySql

    MYSQLD******************************************************************************************

    拷贝mysqld到etc/init.d

    cp /D/programfiles/MySql/support-files/mysql.server /etc/init.d/mysqld

    修改mysqld

    vim /etc/init.d/mysqld
    basedir=/D/programfiles/MySql
    datadir=/D/programfiles/MySql/data

    设置权限

    chmod +x /etc/init.d/mysqld

    设置开机启动MySql

    chkconfig --add mysqld
    chkconfig --level 345 mysqld on

    启动MySql(先配置MY.CNF后再启动)

    /etc/init.d/mysqld start 或 service mysqld start

    运行MySql

    mysql

    mysql -u root -p

    关闭MySql

    /etc/init.d/mysqld stop 或 service mysqld stop

    到这里安装结束

    其他部分之(MY.CNF)***************************************************************************************

    cp /D/programfiles/MySql/support-files/my-default.cnf /etc/my.cnf

    vim /etc/my.cnf # 修改my.cnf(添加一些内容)

    [mysqld]
    #用户
    user=mysql

    #启动MySql的临时文件
    socket=/D/programfiles/MySql/mysql.sock

    #MySql根路径
    basedir=/D/programfiles/MySql

    #MySql数据存放目录
    datadir=/D/programfiles/MySql/data

    #启动MySql的临时文件
    pid-file=/D/programfiles/MySql/mysqld.pid

    #MySql错误日志目录
    log-error=/D/programfiles/MySql/logs/mysqld.log

    [mysqld_safe]
    pid-file=/D/programfiles/MySql/mysqld.pid
    log-error=/D/programfiles/MySql/logs/mysqld.log

    [client]
    port=3306
    socket=/D/programfiles/MySql/mysql.sock

    参考网站**********************************************************************************************

    http://www.osyunwei.com/archives/5970.html

    常见错误**********************************************************************************************

    mysqld_safe error: log-error set to ‘/D/programfiles/MySql/logs/mysqld.log’, however file don’t exists. Create writable for user ‘mysql’
    原因:没有指定路径,且没有该路径的权限
    解决:
    mkdir /var/log/mariadb
    touch /var/log/mariadb/mariadb.log
    chown -R mysql:mysql /var/log/mariadb

    mysqld_safe error: log-error set to ‘/D/programfiles/MySql/logs/mysqld.log’, however file don’t exists. Create writable for user ‘mysql’.
    mkdir /D/programfiles/MySql/logs
    touch /D/programfiles/MySql/logs/mysqld.log
    chown -R mysql:mysql /D/programfiles/MySql/logs

    error while loading shared libraries: libaio.so.1: cannot open shared object file: No such file or directory
    原因:缺少libaio.so.1包
    解决:yum install libaio

    ERROR 2002 (HY000): Can’t connect to local MySQL server through socket ‘/tmp/mysql.sock’ (2)
    原因:没有配置[client]的socket,应该和[mysqld]中的socket配置一致
    解决:配置[client]的socket

    Access denied for user ‘root’@‘localhost’ (using password: YES)
    原因:没权限
    解决:先在[mysqld]中配置skip-grant-tables然后去设置权限,再删除

    (HY000): You must reset your password using ALTER USER statement before executing this statement.
    原因:没有设置远程权限
    解决:修改mysql的root用户密码(即可生效)
    ALTER USER ‘root’@‘localhost’ IDENTIFIED BY ‘111111’;
    或(当有设置Host=‘%‘时使用如下语句)
    ALTER USER ‘root’@’%’ IDENTIFIED BY ‘111111’;

    刷新MYSQL配置

    flush privileges;

  • 相关阅读:
    Linux--I/O复用之select
    【汇编语言王爽】学习笔记-p40-p54
    【最多等和不相交连续子序列】python实现-附ChatGPT解析
    算法分析与设计CH11:关于分治的其他算法——矩阵乘法的分治、最大子数组和的分治求解
    sqlserver union和union all 的区别
    [C++](8)模板的初步了解
    ElasticSearch学习和使用 (使用head软件可视化es数据)
    【mcuclub】STC89C52单片机最小系统讲解
    Redis主从复制
    [附源码]java毕业设计基于的城镇住房公积金管理系统
  • 原文地址:https://blog.csdn.net/ice666_1/article/details/127688890