centos7安装msql

系统版本:CentOS Linux release 7.2.1511 (Core)

mysql版本:mysql-5.6.40.tar.gz

安装步骤:

1、创建用户:

shell > groupadd mysql

shell > useradd -s /sbin/nologin -g mysql -M mysql

shell > yum -y install cmake

2、解压

shell > tar zxvf mysql-5.6.33.tar.gz

shell > tcd mysql-5.6.33

3、配置编译

cmake \

-DCMAKE_INSTALL_PREFIX=/usr/local/mysql \

-DMYSQL_DATADIR=/usr/local/mysql/data \

-DSYSCONFDIR=/etc \

-DENABLED_LOCAL_INFILE=1 \

-DWITH_PARTITION_STORAGE_ENGINE=1 \

-DEXTRA_CHARSETS=all \

-DDEFAULT_CHARSET=utf8 \

-DDEFAULT_COLLATION=utf8_general_ci \

-DWITH_SSL=bundled

报错信息:

CMake Error: CMAKE_C_COMPILER not set, after EnableLanguage
CMake Error: Internal CMake error, TryCompile configure of cmake failed
-- Looking for readlink - not found
-- Looking for re_comp
CMake Error at /usr/share/cmake/Modules/CMakeCInformation.cmake:37 (get_filename_component):
  get_filename_component called with incorrect number of arguments
Call Stack (most recent call first):
  CMakeLists.txt:3 (PROJECT)

解决:

shell > yum install -y gcc

shell > yum install -y gcc-c++

删除编译文件,重新编译

shell > rm -f CMakeCache.txt

报错:

CMake Error at cmake/readline.cmake:85 (MESSAGE):
  Curses library not found.  Please install appropriate package,

      remove CMakeCache.txt and rerun cmake.On Debian/Ubuntu, package name is libncurses5-dev, on Redhat and derivates it is ncurses-devel.

解决依赖:

shell > yum -y install ncurses-devel

然后删除编译文件,继续cmake

shell > make && make install

配置:

授权:

shell > chown -R mysql:mysql /usr/local/mysql

shell > cp /usr/local/mysql/support-files/my-default.cnf /etc/my.cnf

初始化数据库:

shell > /usr/local/mysql/scripts/mysql_install_db --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --user=mysql

报错:

FATAL ERROR: please install the following Perl modules before executing /usr/local/mysql/scripts/mysql_install_db:
Data::Dumper

解决方法:

shell > yum install -y autoconf

添加启动脚本:

shell > cp /usr/local/mysql/support-files/mysql.server /etc/rc.d/init.d/mysqld

shell > chmod +x /etc/rc.d/init.d/mysqld

shell > service mysqld start

shell > chkconfig --add mysqld(添加服务管理)

shell > chkconfig mysqld on(增加之后默认已经自启,此条可以不执行)

添加环境变量

shell > echo 'PATH=/usr/local/mysql/bin:$PATH' >> /etc/profile

shell > echo 'export PATH' >> /etc/profile

shell > source /etc/profile

处理匿名登录和无密码问题:

mysql > select Host,User,Password from mysql.user;

mysql > delete from mysql.user where User=’’;

mysql > update mysql.user set Password = password('123456');

mysql > flush privileges;

 

 

 

 

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值