温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

glibc方式安装mysql

发布时间:2020-07-15 01:56:24 来源:网络 阅读:2273 作者:知者不言 栏目:MySQL数据库

下载安装包 mysql-5.6.38-linux-glibc2.12-x86_64.tar.gz
创建mysql用户
useradd -r mysql -s /sbin/nologin
解压文件
tar -zxvf mysql-5.6.38-linux-glibc2.12-x86_64.tar.gz -C /opt/
改名
mv /opt/mysql-5.6.38-linux-glibc2.12-x86_64/ /opt/mysql-5.6
创建数据目录
mkdir /data
更改目录属组

chown -R mysql.mysql /data
chown -R mysql.mysql /opt/mysql-5.6/

安装mysql

 cd /opt/mysql-5.6/scripts/
 ./mysql_install_db --basedir=/opt/mysql-5.6/ --datadir=/data --user=mysql --pid-file=/opt/mysql-5.6/mysql.pid

安装mysql报错
FATAL ERROR: please install the following Perl modules before executing
缺少autoconf 包
yum-y install autoconf
error while loading shared libraries: libaio.so.1:
缺少libaio-devel包
yum -y install libaio-devel
添加启动脚本
cp /opt/mysql-5.6/support-files/mysql.server /etc/init.d/mysqld

修改配置文件

vi /etc/my.cnf
[mysqld]
 basedir = /opt/mysql-5.6
 datadir = /data
 socket = /tmp/mysql.sock
 pid-file =/opt/mysql-5.6/mysql.pid
 log-bin=mysql-bin
 binlog_format=mixed
 character-set-server = utf8
 max_connections = 3000
 default_storage_engine = InnoDB
 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
 interactive_timeout = 28800
 wait_timeout = 28800
 lower_case_table_names=1
 event_scheduler=1
 skip-name-resolve=1
[mysqldump]
 quick
 max_allowed_packet = 32M

启动mysql

/etc/init.d/mysqld start

修改root密码

cd /opt/mysql-5.6
./bin/mysqladmin -u root password '123'

登录mysql

cd  /opt/mysql-5.6
./bin/mysql -uroot -p'123'

删除空用户和空密码

delete from mysql.user where user='';
delete from mysql.db where user='';

报错

ERROR 2002 (HY000): Can't connect to local MySQL server through socket 
'/tmp/mysql.sock' (2)

找到mysql.sock文件,然后做个软连接
ln -s /opt/mysql-5.6/mysql.sock /tmp/mysql.sock

向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI