linux install mysql

1 篇文章 0 订阅

源码编译安装mysql

wget http://dev.mysql.com/get/Downloads/MySQL-5.6/mysql-5.6.23.tar.gz 
tar zxvf mysql-5.6.23.tar.gz 
cd mysql-5.6.23

#cmake 生成makefile
cmake \
-DCMAKE_INSTALL_PREFIX=${LOCAL_PATH}/usr/local/mysql \
-DMYSQL_DATADIR=${LOCAL_PATH}/usr/local/mysql/data \
-DSYSCONFDIR=${LOCAL_PATH}/etc \
-DWITH_MYISAM_STORAGE_ENGINE=1 \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_MEMORY_STORAGE_ENGINE=1 \
-DWITH_READLINE=1 \
-DMYSQL_UNIX_ADDR=${LOCAL_PATH}/var/lib/mysql/mysql.sock \
-DMYSQL_TCP_PORT=3306 \
-DENABLED_LOCAL_INFILE=1 \
-DWITH_PARTITION_STORAGE_ENGINE=1 \
-DEXTRA_CHARSETS=all \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci .
# cmake相关参数参考:http://dev.mysql.com/doc/refman/5.5/en/source-configuration-options.html#cmake-general-options

make -j16
make install 

#进入安装路径,执行初始化配置脚本,创建系统自带的数据库和表
scripts/mysql_install_db --basedir=$LOCAL_PATH/usr/local/mysql --datadir=$LOCAL_PATH/usr/local/mysql/data --user=xxxxxxoooo
#执行后返回如下结果
# PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !To do so, start the server, then issue the following commands:

  $LOCAL_PATH/usr/local/mysql/bin/mysqladmin -u root password 'new-password'
  $LOCAL_PATH/usr/local/mysql/bin/mysqladmin -u root -h g01 password 'new-password'

#Alternatively you can run:
  $LOCAL_PATH/usr/local/mysql/bin/mysql_secure_installation
#which will also give you the option of removing the test databases and anonymous user created by default.  This is strongly recommended for production servers.See the manual for more instructions.You can start the MySQL daemon with:
  cd . ; $LOCAL_PATH/usr/local/mysql/bin/mysqld_safe &
#You can test the MySQL daemon with mysql-test-run.pl
  cd mysql-test ; perl mysql-test-run.pl

Please report any problems at http://bugs.mysql.com/
The latest information about MySQL is available on the web at http://www.mysql.com Support MySQL by buying support/licenses at http://shop.mysql.com

New default config file was created as $LOCAL_PATH/usr/local/mysql/my.cnf and
will be used by default by the server when you start it.
You may edit this file to change server settings

WARNING: Default config file /etc/my.cnf exists on the system
This file will be read by default by the MySQL server
If you do not want to use this, either remove it, or use the
--defaults-file argument to mysqld_safe when starting the server

#运行mysql 
mkdir -p $LOCAL_PATH/var/lib/mysql
cd . ; $LOCAL_PATH/usr/local/mysql/bin/mysqld_safe --defaults-file=$LOCAL_PATH/usr/local/mysql/my.cnf --user=xxxxxooooo &
#修改mysql 密码 
$LOCAL_PATH/usr/local/mysql/bin/mysqladmin -u root password

mysql配置文件

# For advice on how to change settings please see  
# http://dev.mysql.com/doc/refman/5.6/en/server-configuration-defaults.html  

[mysqld]  

# Remove leading # and set to the amount of RAM for the most important data  
# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.  
# innodb_buffer_pool_size = 128M  

# Remove leading # to turn on a very important data integrity option: logging  
# changes to the binary log between backups.  
# log_bin  

# These are commonly set, remove the # and set as required.  
# basedir = .....  
# datadir = /data/mysql/data  
# port = .....  
# server_id = .....  
# socket = .....  

# Remove leading # to set options mainly useful for reporting servers.  
# The server defaults are faster for transactions and fast SELECTs.  
# Adjust sizes as needed, experiment to find the optimal values.  
# join_buffer_size = 128M  
# sort_buffer_size = 2M  
# read_rnd_buffer_size = 2M   

max_connection = 10000  
sql_mode = NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES   

#binary log   
log-bin = mysql-bin  
binlog_format = mixed  
expire_logs_day = 30  

#slow query log   
slow_query_log = 1  
slow_query_log_file = /var/log/mysql/slow.log  
long_query_time = 3  
log-queries-not-using-indexes  
log-slow-admin-statements  

mysql权限管理

user mysql
SELECT User, Password, Host FROM user; -- 查看现有用户,密码及允许连接的主机
GRANT ALL PRIVILEGES ON *.* TO 'root'@'192.168.1.100' IDENTIFIED BY '' WITH GRANT OPTION;
flush privileges;

#修改root 密码 
update user set password=PASSWORD('123456') where user='root';
flush privileges;

创建可远程访问的用户

grant all privileges on *.* to 'dong'@'%' identified by '123456' with grant option;
flush privileges
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值