• Mysql编译安装


    mysql应用编译安装:

    • 修改配置文件:
    # wget -c https://downloads.mysql.com/archives/get/file/mysql-5.6.25.tar.gz
    # apt-get -y install make gcc g++ cmake perl vim
    # apt-get install make gcc g++ libcurl3-openssl-dev libfreetype6-dev libmcrypt-dev
    # apt-get install libpcre3 libpcre3-dev zlib1g-dev libssl-dev build-essential
    # apt-get install openssl libssl-dev
    # groupadd -r mysql
    # useradd -g mysql -r -d /mydata/data mysql
    # mkdir /mydata/data -pv
    # tar xf mysql-5.6.25.tar.gz 
    # cd mysql-5.6.25
    # vim cmd-line-utils/libedit/terminal.c
    		把terminal_set方法中的 char buf[TC_BUFSIZE]; 这一行注释,再把 area = buf;改为 area = NULL;
    		protected int
    		terminal_set(EditLine *el, const char *term)
    		{ 
    		int i; 
    		/*char buf[TC_BUFSIZE];*/
    		char *area;
    		...
    		area = NULL;
    # cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql 
    		  -DMYSQL_DATADIR=/mydata/data 
    		  -DSYSCONFDIR=/etc 
    		  -DWITH_INNOBASE_STORAGE_ENGINE=1 
    		  -DWITH_ARCHIVE_STORAGE_ENGINE=1 
    		  -DWITH_BLACKHOLE_STORAGE_ENGINE=1 
    		  -DWITH_READLINE=1 
    		  -DWITH_SSL=system 
    		  -DWITH_ZLIB=system 
    		  -DWITH_LIBWRAP=0 
    		  -DMYSQL_UNIX_ADDR=/tmp/mysql.sock 
    		  -DDEFAULT_CHARSET=utf8 
    		  -DDEFAULT_COLLATION=utf8_general_ci
    # make
    # make install
    # cd /usr/local/mysql
    # sudo chown -R mysql:mysql ./
    # sudo chown -R mysql:mysql /mydata/data
    # cp support-files/my-default.cnf /etc/my.cnf
    # sudo chown mysql:mysql /etc/my.cnf
    
    • 修改配置文件:
    # sudo vi /etc/my.cnf 
    	[client] 
    	port = 3306 
    	socket = /usr/local/mysql/data/mysql.sock
    
    	[mysqld] 
    	port = 3306 
    	socket = /usr/local/mysql/data/mysql.sock 
    	basedir = /usr/local/mysql 
    	datadir = /usr/local/mysql/data
    
    • 初始化数据库
    # cd /usr/local/mysql 
    # sudo scripts/mysql_install_db –user=mysql –basedir=/usr/local/mysql –datadir=/usr/local/mysql/data/
    
    • 启动mysql服务
    # 方法1:
    	# 直接启动 
    	# bin/mysqld_safe &
    	# 检查MySQL服务是否启动:
    	# ps -ef |grep mysql
    # 方法2:
    	# 通过服务启动
    	# 添加服务,复制启动脚本到/etc/init.d目录:
    
    	# cd /usr/local/mysql/
    	# cp support-files/mysql.server /etc/init.d/mysql
    	# 设置文本的权限:
    	# sudo chmod 755 /etc/init.d/mysql
    
    	# 启动:
    	# sudo /etc/init.d/mysql start
    	# (关闭mysql服务:sudo /etc/init.d/mysql stop)
    	# 或者
    	# sudo service mysql start
    	# (关闭mysql服务:sudo service mysql stop)
    	# 检查MySQL服务是否启动:
    	# ps -ef |grep mysql
    
    • 配置环境变量
    # 为了直接调用mysql,需要将mysql的bin目录加入PATH环境变量。
    # 编辑/etc/profile.d/:
    # sudo vim /etc/profile.d/mysql
    	PATH=$PATH:/usr/local/mysql/bin
    	export PATH
    # 关闭文件,运行下面的命令,让配置立即生效:
    # source /etc/profile
    
    • 修改root密码(因为默认密码为空)
    # mysql -h127.0.0.1 -uroot -p
    # update mysql.user set password=password('root') where user='root'; 
    # flush privileges;
    # service mysql restart
    
    • 开机自启动
    # update-rc.d nginx defaults 99
    
    • mysql测试语句:
    # mysql> select now(),user(),version(); 
    +---------------------+------------------+-----------+
    | now()               | user()           | version() |
    +---------------------+------------------+-----------+
    | 2018-08-27 19:00:59 | evescn@localhost | 5.6.25    |
    +---------------------+------------------+-----------+
    # CREATE DATABASE IF NOT EXISTS evescn DEFAULT CHARSET utf8 COLLATE utf8_general_ci;
    # CREATE TABLE IF NOT EXISTS `runoob_tbl`(
    	   `runoob_id` INT UNSIGNED AUTO_INCREMENT,
    	   `runoob_title` VARCHAR(100) NOT NULL,
    	   `runoob_author` VARCHAR(40) NOT NULL,
    	   `submission_date` DATE,
    	   PRIMARY KEY ( `runoob_id` )
    	)ENGINE=InnoDB DEFAULT CHARSET=utf8;
    # INSERT INTO runoob_tbl
    	(runoob_title, runoob_author, submission_date)
    	VALUES
    	("学习 MySQL", "菜鸟教程", NOW());
    # INSERT INTO runoob_tbl 
    	(runoob_title, runoob_author, submission_date)
    	VALUES
    	("学习 PHP", "菜鸟教程", NOW());
    
  • 相关阅读:
    CSS——如何清除浮动
    CSS——display(Block none inline等)属性的用法
    css3——position定位详解
    [转载]mysql创建临时表,将查询结果插入已有表中
    [转载]基于LVS的AAA负载均衡架构实践
    Percona Toolkit 2.2.19 is now available
    [转载]使用awk进行数字计算,保留指定位小数
    [转载]github在线更改mysql表结构工具gh-ost
    [转载]binlog归档
    [转载]MySQL运行状态show status详解
  • 原文地址:https://www.cnblogs.com/evescn/p/10692308.html
Copyright © 2020-2023  润新知