Mysql set up in Linux

  In this construction, there have been various problems have been solved can not afford to suggest that small partners do not like me, like a headless flies, that there are problems to solve this problem, there is no real sense of the nature of the problem.

  The main problem (starred, standard focus): Be sure to look at their own version of linux, mysql Do not download a direct installation, the installation in the end, is also running out, because the binary to execute the program simply do not use. For example: mysqld, display not found. The following is the correct installation method:

  First, check your linux operating system are few, and download the appropriate software according to their own system Mysql the median, my linux is 64.

    # uname -i

    

  Second, download the installation package is good, I downloaded on training materials: MySQL-5.6.35-Linux-glibc2.5-x86_64.tar.gz , the file extension is tar.gz .

  

 

  Then download windows good software, copied to the desktop virtual machine, the file name is tar.gz, apparently compressed with tar and gzip.

  Third, unzip, then copied into the file to decompress it with the command: tar zxvf mysql-5.6.35-linux-glibc2.5-x86_64.tar.gz, then there is an extract from the folder, extract the complete mobile directory and change the name to mysql. Then move the file to determine / usr / local path is the same as in the original folder, change the name of the command to the other and then the mysql folder to the path:

   # Cd Desktop

   # && mv /usrlocal/mysql /usr/local/mysql_old 

   # mv mysql-5.6.35-linux-glibc2.5-x86_64 /usr/local/mysql

 

   Fourth, the establishment MySQL user, the user needs to start mysql:

      # useradd -s /sbin/nologin mysql

       # cd /usr/local/mysql

         Creating datadir, database files are put here:

      # mkdir -p data/mysql

    Change permissions, or later will get an error:

      # chown -R mysql:mysql data/mysql

    Initialized for the specified user mysql, the data storage path specified /usr/local/mysql/data/mysql:

      # ./scripts/mysql_install_db --user=mysql --datadir=/usr/local/mysql/data/mysql

            

      

 

 

      We can see, there were two OK above, which indicates successful initialization. If you do not succeed, probably because something is not installed, the first time, go to the local Baidu appears ERROR. For example: c with gcc not installed, "Please the install modules before the Perl The following Executing ./scripts/mysql_install_db: the Data :: Dumper" , "Directory of The parent for The Data Directory '/ Data / MySQL' path that does Not exist.If was really intended, please create that directory path and thenrestart this script. " and so on.

     Solution: 1, appears: "Please  install the before at The following Perl modules Executing ./scripts/mysql_install_db: the Data :: Dumper", with the following command-line installation (remember networking)

            First look:

            # yum list |grep perl | grep -i Dumper 

            

 

             不知道的情况下,可以一个个去安装上面的包,这里我们知道是第一个,使用yum安装

           # yum install -y perl-Data-Dumper.x86_64  

           再次初始化:# ./scripts/mysql_install_db --user=mysql --datadir=/usr/local/mysql/data/mysql

 

 

           2、出现:”The parent directory for the data directory '/data/mysql' does not exist.If that path was really intended, please create that directory path and thenrestart this script.“,是提示没有这样的目录或文件,我们需要在data/mysql前面加上绝对路径:# ./scripts/mysql_install_db --user=mysql --datadir=/usr/local/mysql/data/mysql  。

          3、提示没有libaio.so.1 ,没有就安装:# yum install -y libaio*

           再次初始化:# ./scripts/mysql_install_db --user=mysql --datadir=/usr/local/mysql/data/mysql

       检验一下:# echo $?   ,输出为0,说明上一条命令已经正确执行。

    五、配置Mysql ,初始化完成之后,接下来就是配置(划重点:路径要一模一样,不然最后启动不了,mysqld 命令报错)。

      首先复制配置文件:# cp support-files/my-default.cnf /etc/my.cnf

       

      打开配置文件,做以下修改:

       

      然后复制启动脚本文件,并修改启动脚本文件的属性:

       # cp support-files/mysql.server /etc/init.d/mysqld

      #  chmod 755 /etc/init.d/mysqld

      #  vim /etc/init.d/mysqld

      

 

       接下来将启动脚本加入系统服务项并设置开机启动:

          # chkconfig --add mysqld

          # chkconfig mysqld on

      最后启动服务:# service mysqld start

      

 

       启动成功!!!上面已经启动成功,如果没有成功启动,我们也可以到/usr/local/mysql//data/mysql目录下查看错误日志。

      检查是否启动成功,命令:# ps aux |grep mysqld

      

 

       停止MySQL服务:# service mysqld stop    停止之后,可以用上一个命令再次查看是否在运行,没有Mysql 即表示关闭成功。

      还可以以命令行的方式启动脚本,--defaults-file指定配置文件,指定用户,指定目录,最后加上&符号,放到后台执行。以命令行的方式启动的mysql脚本不能直接stop,可以使用killall停止服务。命令如下:

         # /usr/local/mysql/bin/mysqld_safe --defaults-file=/etc/my.cnf --user=mysql --datadir=/data/mysql &

 

最后,安装完成!!!!!开心,一个星期才解决,因为这个安装不上,影响php 的安装,所以,我的学习进度变的很慢。

       

     

Guess you like

Origin www.cnblogs.com/zblock/p/12037401.html