MySql教程

Alibaba Cloud Linux 3.2104 64位安装mysql5.6.45

本文主要是介绍Alibaba Cloud Linux 3.2104 64位安装mysql5.6.45,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!

 

1 、安装cmake

          wget http://www.cmake.org/files/v2.8/cmake-2.8.10.2.tar.gz

          tar -zxvf cmake-2.8.10.2.tar.gz

          cd cmake-2.8.10.2

          ./configure

          make

          make install

          make clean

          到此 cmake安装完毕

 

2 、安装 mysql

       1 把下载好的mysql安装包上传到linux服务器  (当前用的是mysql-5.6.45.tar.gz)

       2 检查是否已经安装mysql

       

      rpm -qa | grep mysql  (如果已经安装了需先卸载)  

        rpm -e --nodeps mysql-libs-5.1.61-4.el6.x86_64  (卸载mysql 卸载版本名称以实际的为准)

     

      3 安装mysql

        

          yum -y install make gcc-c++ bison-devel  ncurses-devel  //安装mysql所需要的依赖包          groupadd mysql (增加mysql用户组)

          useradd -g mysql -s /sbin/nologin mysql  (增加mysql用户 不允许直接登录)

          tar -zxvf mysql-5.6.26.tar.gz

          cd mysql-5.6.26

          cmake . 
          -DCMAKE_INSTALL_PREFIX=/usr/local/mysql
          -DMYSQL_DATADIR=/usr/local/mysql/data
          -DDEFAULT_CHARSET=utf8
          -DDEFAULT_COLLATION=utf8_general_ci
          -DEXTRA_CHARSETS=all 
          -DENABLED_LOCAL_INFILE=1   (cmake 编译mysql)
          make
          make install
          make clean
          chown -R mysql:mysql /usr/local/mysql

          chmod 755 /usr/local/mysql/scripts/mysql_install_db (赋给文件执行权限)

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

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

          chmod 755 /etc/init.d/mysqld

          chkconfig --add mysqld

          chkconfig mysqld on                    编辑 /etc/init.d/my.cnf //mysql的配置文件写入如下内容 根据实际情况修改      #########################################################
             [client]             default-character-set = utf8             port = 3306             socket = /tmp/mysql.sock

            [mysqld]            socket=/tmp/mysql.sock            port = 3306            basedir = /usr/local/mysql            datadir=/www/mysql/data            pid-file = /www/mysql/data/mysql.pid            user = mysql            bind-address = 0.0.0.0            server-id = 1            skip-name-resolve            back_log = 600            max_connections = 1000            max_connect_errors = 6000            open_files_limit = 65535            table_open_cache = 128             max_allowed_packet = 4M            binlog_cache_size = 1M            max_heap_table_size = 8M            tmp_table_size = 16M

            read_buffer_size = 2M            read_rnd_buffer_size = 8M            sort_buffer_size = 8M            join_buffer_size = 8M            key_buffer_size = 4M
            thread_cache_size = 8
            query_cache_size = 8M            query_cache_limit = 2M
            ft_min_word_len = 4
            log_bin = mysql-bin            binlog_format = mixed            expire_logs_days = 30
            log_error = /www/mysql/data/mysql-error.log            slow_query_log = 1            long_query_time = 1            slow_query_log_file = /www/mysql/data/mysql-slow.log
            performance_schema = 0            explicit_defaults_for_timestamp
            #lower_case_table_names = 1
            skip-external-locking
            default_storage_engine = InnoDB            #default-storage-engine = MyISAM            innodb_file_per_table = 1            innodb_open_files = 500            innodb_buffer_pool_size = 64M            innodb_write_io_threads = 4            innodb_read_io_threads = 4            innodb_thread_concurrency = 0            innodb_purge_threads = 1            innodb_flush_log_at_trx_commit = 2            innodb_log_buffer_size = 2M            innodb_log_file_size = 32M            innodb_log_files_in_group = 3            innodb_max_dirty_pages_pct = 90            innodb_lock_wait_timeout = 120
            bulk_insert_buffer_size = 8M            myisam_sort_buffer_size = 8M            myisam_max_sort_file_size = 10G            myisam_repair_threads = 1
          interactive_timeout = 28800
            wait_timeout = 28800

            [mysqldump]              quick              max_allowed_packet = 16M

            [myisamchk]              key_buffer_size = 8M              sort_buffer_size = 8M              read_buffer = 4M              write_buffer = 4M
      ##########################################################      
          service mysqld restart

          添加到环境变量

          vi  /etc/profile

          添加如下代码 export PATH="$PATH:/usr/local/mysql/bin"

          source  /etc/profile

          登录mysql

          mysql -uroot -p  //登陆mysql  第一次登陆的时候不需要输入密码

          use mysql;

          delete from user where User=''; //删除用户名为空的用户

          UPDATE user SET password=PASSWORD("123456") WHERE user='root'; //修改root用户的密码

 
         mysql增加用户的命令

         grant all privileges on db_test.* to db_user@"%" identified by '123456' with grant option;

         这样就为 数据库 db_test 增加了一个  db_user的用户操作的权限 默认密码为  123456

         flush privileges;//刷新权限                  重启服务器,看mysql是否随着开机启动

 

         

    

这篇关于Alibaba Cloud Linux 3.2104 64位安装mysql5.6.45的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!