Spring MVC+tomcat+mysql+Ubuntu项目部署的笔记

安装文件是mysql-5.6.31-linux-glibc2.5-x86_64.tar.gz,将解压后的mysql文件放在/usr/local目录下。

在mysql的scripts目录下执行 ./mysql_install_db --user=deploy --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data命令

第一次执行的时候确实以来,补上以来即可,第二次执行以上命令执行成功;提示信息如下:

Installing MySQL system tables...2016-07-11 11:05:32 0 [Warning] Ignoring user change to 'deploy' because the user was set to 'mysql' earlier on the command line

2016-07-11 11:05:32 0 [Note] /usr/local/mysql/bin/mysqld (mysqld 5.6.31) starting as process 22775 ...
OK

Filling help tables...2016-07-11 11:05:34 0 [Warning] Ignoring user change to 'deploy' because the user was set to 'mysql' earlier on the command line

2016-07-11 11:05:34 0 [Note] /usr/local/mysql/bin/mysqld (mysqld 5.6.31) starting as process 22798 ...
OK

To start mysqld at boot time you have to copy
support-files/mysql.server to the right place for your system

PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To do so, start the server, then issue the following commands:

  /usr/local/mysql/bin/mysqladmin -u root password 'new-password'
  /usr/local/mysql/bin/mysqladmin -u root -h ubuntu password 'new-password'

Alternatively you can run:

  /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 . ; /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

WARNING: Found existing config file /usr/local/mysql/my.cnf on the system.
Because this file might be in use, it was not replaced,
but was used in bootstrap (unless you used --defaults-file)
and when you later start the server.
The new default config file was created as /usr/local/mysql/my-new.cnf,
please compare it with your file and take the changes you need.

WARNING: Default config file /etc/mysql/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用户进行执行,以及提示设置为开机启动的方式和设置root密码

忽略,直接运行/usr/local/mysql/bin/mysqld 开始Mysql服务。为什么是mysqld呢?start参数呢?不知道,加上start后,会提示参数多余,而结束的时候只能kill掉线程。

启动将不成功,因为会出现这个网址的问题点击打开链接,也就是mysql提示为了安全起见不要使用root身份进行开启服务,详情见链接。

于是可以执行:sudo -u mysql /usr/local/mysql/bin/mysqld这个命令可以成功开启服务。另一个方式是在my.cnf配置文件中的[mysqld]下添加user=mysql来指定使用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 = D:\mysql5.6
# datadir =D:\mysql5.6\data
# port = .....
# server_id = .....


# 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 

character_set_server=utf8

sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES 

[client]
default-character-set=utf8

[mysql]
default-character-set=utf8
最好在[mysqld]、[client]、[mysql]下添加设置默认编码utf8,以免在使用数据库时中文乱码。

需要注意的是,mysql服务启动时,会读取配置文件my.cnf,而在操作系统中可以有多个配置文件,详见这里点击打开链接,关于多个配置mysql读取的优先级。

对了,关于数据库配置文件方面,添加lower_case_table_names=1表示不区分大小写,=0为区分大小写,比如表名列明的大小写。如果想避免大小的想问题,可以你最好在定义数据库命名规则的时候就全部采用小写字母加下划线的组合,而不使用任何的大写字母。

最后附上关于sql_mode的配置博客点击打开链接

由于是部署,所以把之前的数据要导入到新的数据库,有关数据库表和数据导出的资料点击打开链接

关于tomcat接收http get请求时的中文乱码,可以查看点击打开链接


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值