1.Ubuntu 默认安装 Mysql 5.6版本以上:
1.查看系统是否安装mysql 数据库:
sudo netstat -tap | grep mysql
如果安装了,就查看一下版本命令:
mysql --version 如果是版本5.5的话,卸载重装。
卸载命令:sudo apt-get autoremove --purge mysql-server-5.5
2. 安装命令:
sudo apt-get install mysql-server-5.6 mysql-client-5.6
安装过程设置root 密码
3.
登入:mysql -u root -p
4.常用命令:
启动服务器:sudo start mysql
停止服务器 :sudo stop mysql
重启服务器:sudo restart mysql
5.安装 MySQL workbench
第一种在:Ubuntu sofeware Center 输入安装:
第二方法,去官网下载对应Ubuntu 版本进行安装:http://dev.mysql.com/downloads/workbench/
下载下来的DEB包,然后双击就可以根据提示进行安装了。
连接本地的数据库,进行使用:
解释: 如果mysql版本小于5.6的话,不能使用workbench 里面提供的 Visual Explain 方法,因为这样分析你查询的代码,这样就能分析,
你代码里面是否循环整张表,从而提高系统性能的分析,查看复杂语句性能分析的时候,可以快速的查看出来,可以进行优化。
6.Ubuntu不支持大小忽略 配置:
1: sudo vim /etc/mysql/my.cnf
2.在[mysqld]下加入一行:lower_case_table_names=1
3.重新启动数据库:
2.Windows 下使用mysql.zip 进行安装mysql并且非C盘安装
1.下载:mysql-5.6.27-winx64.zip
2.然后解压到对应的路径我的路径为:D:Program FilesMySQLmysql-5.6.27-winx64
3.拷贝一份 my-default.ini 文件,取名为my.ini
修改里面的两个属性:
basedir =D:Program FilesMySQLmysql-5.6.27-winx64
datadir =D:Program FilesMySQLmysql-5.6.27-winx64data
4.配置全局变量:
MYSQL_HOME D:Program FilesMySQLmysql-5.6.27-winx64
PATH %MYSQL_HOME%in
5.进入命令行模式使用管理员打开cmd 窗口:
一定要进入到你mysql的安装目录如:
cd :D:Program FilesMySQLmysql-5.6.27-winx64in
6. 执行安装命令
mysqld -install
7.启动数据库后台进程
net start mysql
8.删除命令:
mysqld -remove
其中我my.ini的配置文件:
# For advice on how to change settings please see # http://dev.mysql.com/doc/refman/5.6/en/server-configuration-defaults.html # *** DO NOT EDIT THIS FILE. It's a template which will be copied to the # *** default location during install, and will be replaced if you # *** upgrade to a newer version of MySQL. [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 = ..... # port = ..... # server_id = ..... basedir=D:/Program Files/MySQL/mysql-5.6.24-winx64 datadir=D:/Program Files/MySQL/mysql-5.6.24-winx64/data port=13306 #自己定义端口 character-set-server=utf8 default-storage-engine=INNODB innodb_data_home_dir=D:/Program Files/MySQL/mysql-5.6.24-winx64/data innodb_data_file_path=ibdata1:12M:autoextend innodb_log_group_home_dir=D:/Program Files/MySQL/mysql-5.6.24-winx64/data innodb_buffer_pool_size=10240M innodb_log_file_size=4G # 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 sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES