Chinaunix首页 | 论坛 | 博客
  • 博客访问: 2124400
  • 博文数量: 281
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 2085
  • 用 户 组: 普通用户
  • 注册时间: 2014-03-31 14:30
个人简介

自己慢慢积累。

文章分类

全部博文(281)

分类: Mysql/postgreSQL

2022-09-27 10:22:05

1. 下载5.7的安装包

  1. wget https://dev.mysql.com/get/mysql-5.7.39-el7-x86_64.tar.gz
想要其他版本,可以在官方网站下载:
https://dev.mysql.com/downloads/mysql/

2. 解压安装
tar -zxvf mysql-5.7.39-el7-x86_64.tar.gz
改个名看着方便,不改也行
mv mysql-5.7.39-el7-x86_64  mysql

进入mysql文件夹,创建一个必要的文件夹
cd mysql
mkdir log tmp var data conf

conf里面创建cnf文件
vim conf/my.cnf
里面的路径需要自己改下

点击(此处)折叠或打开

  1. [mysqld]
  2. user = uplus
  3. port = 3306
  4. key_buffer_size = 256M
  5. max_allowed_packet = 256M
  6. slave_max_allowed_packet = 256M
  7. table_open_cache = 512
  8. sort_buffer_size = 2M
  9. net_buffer_length = 8K
  10. read_buffer_size = 2M
  11. read_rnd_buffer_size = 512K
  12. myisam_sort_buffer_size = 64M
  13. thread_cache_size = 64
  14. query_cache_size = 64M
  15. max_connections = 32000
  16. tmp_table_size = 128M
  17. long_query_time = 3
  18. slow_query_log
  19. innodb_buffer_pool_size = 7000M
  20. innodb_flush_log_at_trx_commit = 0
  21. innodb_flush_method = O_DIRECT
  22. innodb_file_format = barracuda
  23. innodb_log_file_size = 1G
  24. innodb_log_files_in_group = 3
  25. character_set_server = utf8
  26. log_timestamps = SYSTEM
  27. #have_statement_timeout = NO
  28. ############### PATH ##############
  29. basedir = /home/uplus/package/mysql
  30. datadir = /home/uplus/package/mysql/data
  31. tmpdir = /home/uplus/package/mysql/tmp
  32. socket = /home/uplus/package/mysql/var/mysql.sock
  33. pid_file = /home/uplus/package/mysql/var/mysql.pid
  34. general_log_file = /home/uplus/package/mysql/log/general.log
  35. innodb_data_home_dir = /home/uplus/package/mysql/data
  36. slow_query_log_file = /home/uplus/package/mysql/log/slow.log
  37. log_error = /home/uplus/package/mysql/log/error.log
  38. sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
  39. [mysql]
  40. default-character-set = utf8

进入mysql/bin 目录,进行安装
./mysqld --initialize --basedir=/home/uplus/package/mysql/ --datadir=/home/uplus/package/mysql/data --user=uplus  --socket=/home/uplus/package/mysql/var --port=3306

如果安装报错:
./mysqld: error while loading shared libraries: libaio.so.1: cannot open shared object file: No such file or directory。
需要安装两个包:
yum install -y libaio.so.1
yum install -y libaio

初始化完成后,{BANNED}最佳后一行会显示root密码,一定要保存下来。



启动mysql
需要根据实际修改路径
  1. nohup bin/mysqld_safe --defaults-file=/home/uplus/package/mysql/conf/my.cnf --socket=/home/uplus/package/mysql/var/mysql.sock &
启动后,必须要对Mysql的root密码就行修改
先登录mysql
bin/mysql -u root -S/home/uplus/package/mysql/var/mysql.sock -p
输入初始的密码
set password=password('123456');

配置远程登陆权限
grant all privileges on *.* to root@'%' identified by '123456';
flush privileges;

查看是否成功
use mysql;
select host,user from user;

退出myql

配置环境变量和开机启动
ln -s /home/hadoop/mysql/var/mysql.sock /tmp/mysql.sock

设置环境变量
export MYSQL_HOME=/home/uplus/package/mysql
export PATH=$MYSQL_HOME/bin:$PATH

如果有root权限 可以设置开机启动
cp support-files/mysql.server /etc/init.d/mysql



停止Mysql服务的方法:

mysqladmin -uroot -p shutdown -S /home/uplus/package/var/mysql.sock







阅读(1922) | 评论(0) | 转发(1) |
0

上一篇:python 对字典、列表、字典列表进行排序

下一篇:没有了

给主人留下些什么吧!~~