“character_set_results”, “character_set_server”の変更方法

mysqlのdatabaseのパラメータである、”character_set_results”, “character_set_server”
の変更方法を記載します。

文字化けなどの対処方法になるかもしれません。

mysql> show variables like 'character_set%';
+--------------------------+----------------------------------------+
| Variable_name            | Value                                  |
+--------------------------+----------------------------------------+
| character_set_client     | latin1                                 |
| character_set_connection | latin1                                 |
| character_set_database   | latin1                                 |
| character_set_filesystem | binary                                 |
| character_set_results    | latin1                                 |
| character_set_server     | latin1                                 |
| character_set_system     | utf8                                   |
| character_sets_dir       | /usr/local/mysql/share/mysql/charsets/ |
+--------------------------+----------------------------------------+
8 rows in set (0.00 sec)

my.cnfに以下を設定するして、mysqldを再起動

default-character-set=utf8
mysql> show variables like 'character_set%';
+--------------------------+----------------------------------------+
| Variable_name            | Value                                  |
+--------------------------+----------------------------------------+
| character_set_client     | latin1                                 |
| character_set_connection | latin1                                 |
| character_set_database   | latin1                                 |
| character_set_filesystem | binary                                 |
| character_set_results    | latin1                                 |
| character_set_server     | utf8                                   |
| character_set_system     | utf8                                   |
| character_sets_dir       | /usr/local/mysql/share/mysql/charsets/ |
+--------------------------+----------------------------------------+
8 rows in set (0.00 sec)

“character_set_database”を変更する方法

“character_set_database”の値が適切でないと、文字化けなどの
不具合が発生する可能性があります。

そこで、”character_set_database”を変更する方法をご紹介します。

以下のようにします。

mysql> alter database mytest character set utf8;
mysql>  show variables like 'character_set%';
+--------------------------+----------------------------+
| Variable_name            | Value                      |
+--------------------------+----------------------------+
| character_set_client     | utf8                       |
| character_set_connection | utf8                       |
| character_set_database   | latin1                     |
| character_set_filesystem | binary                     |
| character_set_results    | utf8                       |
| character_set_server     | latin1                     |
| character_set_system     | utf8                       |
| character_sets_dir       | /usr/share/mysql/charsets/ |
+--------------------------+----------------------------+
8 rows in set (0.00 sec)

mysql>
mysql>

mysql> alter database hogedb character set utf8;
Query OK, 1 row affected (0.00 sec)

mysql>  show variables like 'character_set%';
+--------------------------+----------------------------+
| Variable_name            | Value                      |
+--------------------------+----------------------------+
| character_set_client     | utf8                       |
| character_set_connection | utf8                       |
| character_set_database   | utf8                       |
| character_set_filesystem | binary                     |
| character_set_results    | utf8                       |
| character_set_server     | latin1                     |
| character_set_system     | utf8                       |
| character_sets_dir       | /usr/share/mysql/charsets/ |
+--------------------------+----------------------------+
8 rows in set (0.00 sec)

nkfのインストール

さくらVPSでは初期状態でnkfコマンドがインストールされてません。

そこで、以下のようにインストールする必要があります。

# yum -y install nkf
Loaded plugins: fastestmirror, security
Loading mirror speeds from cached hostfile
 * base: ftp.iij.ad.jp
 * epel: ftp.kddilabs.jp
 * extras: ftp.iij.ad.jp
 * updates: ftp.iij.ad.jp
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package nkf.x86_64 1:2.0.8b-6.2.el6 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

=========================================================================================================
 Package             Arch                   Version                           Repository            Size
=========================================================================================================
Installing:
 nkf                 x86_64                 1:2.0.8b-6.2.el6                  base                 110 k

Transaction Summary
=========================================================================================================
Install       1 Package(s)

Total download size: 110 k
Installed size: 241 k
Downloading Packages:
nkf-2.0.8b-6.2.el6.x86_64.rpm                                                     | 110 kB     00:00
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
  Installing : 1:nkf-2.0.8b-6.2.el6.x86_64                                                           1/1
  Verifying  : 1:nkf-2.0.8b-6.2.el6.x86_64                                                           1/1

Installed:
  nkf.x86_64 1:2.0.8b-6.2.el6

Complete!

Smartyをインストールする

さくらVPSではもちろん、Smartyがインストールされてないので、
Smartyをインストールします。

最新版のURLは以下から確認してください。
http://www.smarty.net/download

1. Smartyをダウンロード

# wget http://www.smarty.net/files/Smarty-3.1.14.tar.gz
--2013-09-29 00:50:43--  http://www.smarty.net/files/Smarty-3.1.14.tar.gz
Resolving www.smarty.net... 192.198.198.106
Connecting to www.smarty.net|192.198.198.106|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 204991 (200K) [application/x-gzip]
Saving to: `Smarty-3.1.14.tar.gz'

100%[===============================================================>] 204,991      261K/s   in 0.8s

2013-09-29 00:50:44 (261 KB/s) - `Smarty-3.1.14.tar.gz' saved [204991/204991]

2. 展開

# ls
MyFunctions.php  Smarty-3.1.14.tar.gz  go-pear.phar
[root@www12079uh ~]# tar xvfz Smarty-3.1.14.tar.gz
Smarty-3.1.14/
Smarty-3.1.14/demo/
Smarty-3.1.14/demo/templates/
Smarty-3.1.14/demo/templates/header.tpl
Smarty-3.1.14/demo/templates/index.tpl
Smarty-3.1.14/demo/templates/footer.tpl
Smarty-3.1.14/demo/templates_c/
Smarty-3.1.14/demo/index.php
Smarty-3.1.14/demo/cache/
Smarty-3.1.14/demo/configs/
Smarty-3.1.14/demo/configs/test.conf
Smarty-3.1.14/demo/plugins/
Smarty-3.1.14/demo/plugins/resource.extendsall.php
Smarty-3.1.14/demo/plugins/cacheresource.apc.php
Smarty-3.1.14/demo/plugins/cacheresource.mysql.php
Smarty-3.1.14/demo/plugins/cacheresource.memcache.php
Smarty-3.1.14/demo/plugins/resource.mysqls.php
Smarty-3.1.14/demo/plugins/resource.mysql.php
Smarty-3.1.14/change_log.txt
Smarty-3.1.14/SMARTY_3.0_BC_NOTES.txt
Smarty-3.1.14/SMARTY_2_BC_NOTES.txt
Smarty-3.1.14/COPYING.lib
Smarty-3.1.14/libs/
Smarty-3.1.14/libs/debug.tpl
Smarty-3.1.14/libs/sysplugins/
Smarty-3.1.14/libs/sysplugins/smarty_cacheresource.php
Smarty-3.1.14/libs/sysplugins/smarty_internal_templatebase.php
Smarty-3.1.14/libs/sysplugins/smarty_internal_compile_assign.php
Smarty-3.1.14/libs/sysplugins/smarty_internal_nocache_insert.php
Smarty-3.1.14/libs/sysplugins/smarty_resource_recompiled.php
Smarty-3.1.14/libs/sysplugins/smarty_internal_compile_private_modifier.php
Smarty-3.1.14/libs/sysplugins/smarty_internal_filter_handler.php
Smarty-3.1.14/libs/sysplugins/smarty_internal_config_file_compiler.php
Smarty-3.1.14/libs/sysplugins/smarty_internal_config.php
Smarty-3.1.14/libs/sysplugins/smarty_internal_templatecompilerbase.php
Smarty-3.1.14/libs/sysplugins/smarty_security.php
Smarty-3.1.14/libs/sysplugins/smarty_internal_resource_registered.php
Smarty-3.1.14/libs/sysplugins/smarty_internal_compile_while.php
Smarty-3.1.14/libs/sysplugins/smarty_internal_compile_capture.php
Smarty-3.1.14/libs/sysplugins/smarty_internal_resource_file.php
Smarty-3.1.14/libs/sysplugins/smarty_internal_resource_extends.php
Smarty-3.1.14/libs/sysplugins/smarty_internal_compile_setfilter.php
Smarty-3.1.14/libs/sysplugins/smarty_internal_cacheresource_file.php
Smarty-3.1.14/libs/sysplugins/smarty_internal_compile_foreach.php
Smarty-3.1.14/libs/sysplugins/smarty_internal_compile_insert.php
Smarty-3.1.14/libs/sysplugins/smarty_internal_compile_private_function_plugin.php
Smarty-3.1.14/libs/sysplugins/smarty_internal_resource_string.php
Smarty-3.1.14/libs/sysplugins/smarty_internal_compile_break.php
Smarty-3.1.14/libs/sysplugins/smarty_internal_data.php
Smarty-3.1.14/libs/sysplugins/smarty_resource_uncompiled.php
Smarty-3.1.14/libs/sysplugins/smarty_internal_compile_include.php
Smarty-3.1.14/libs/sysplugins/smarty_internal_smartytemplatecompiler.php
Smarty-3.1.14/libs/sysplugins/smarty_internal_configfilelexer.php
Smarty-3.1.14/libs/sysplugins/smarty_internal_resource_php.php
Smarty-3.1.14/libs/sysplugins/smarty_internal_configfileparser.php
Smarty-3.1.14/libs/sysplugins/smarty_internal_compile_private_object_function.php
Smarty-3.1.14/libs/sysplugins/smarty_cacheresource_keyvaluestore.php
Smarty-3.1.14/libs/sysplugins/smarty_internal_debug.php
Smarty-3.1.14/libs/sysplugins/smarty_internal_compile_if.php
Smarty-3.1.14/libs/sysplugins/smarty_internal_compile_config_load.php
Smarty-3.1.14/libs/sysplugins/smarty_internal_compile_include_php.php
Smarty-3.1.14/libs/sysplugins/smarty_internal_template.php
Smarty-3.1.14/libs/sysplugins/smarty_internal_compile_function.php
Smarty-3.1.14/libs/sysplugins/smarty_internal_compile_ldelim.php
Smarty-3.1.14/libs/sysplugins/smarty_resource.php
Smarty-3.1.14/libs/sysplugins/smarty_internal_compile_append.php
Smarty-3.1.14/libs/sysplugins/smarty_internal_compile_section.php
Smarty-3.1.14/libs/sysplugins/smarty_internal_compile_eval.php
Smarty-3.1.14/libs/sysplugins/smarty_internal_compile_private_print_expression.php
Smarty-3.1.14/libs/sysplugins/smarty_internal_compile_continue.php
Smarty-3.1.14/libs/sysplugins/smarty_internal_compile_block.php
Smarty-3.1.14/libs/sysplugins/smarty_internal_templatelexer.php
Smarty-3.1.14/libs/sysplugins/smarty_config_source.php
Smarty-3.1.14/libs/sysplugins/smarty_internal_compile_rdelim.php
Smarty-3.1.14/libs/sysplugins/smarty_internal_compile_private_registered_function.php
Smarty-3.1.14/libs/sysplugins/smarty_internal_resource_stream.php
Smarty-3.1.14/libs/sysplugins/smarty_internal_resource_eval.php
Smarty-3.1.14/libs/sysplugins/smarty_internal_compile_for.php
Smarty-3.1.14/libs/sysplugins/smarty_resource_custom.php
Smarty-3.1.14/libs/sysplugins/smarty_internal_compile_private_special_variable.php
Smarty-3.1.14/libs/sysplugins/smarty_internal_compilebase.php
Smarty-3.1.14/libs/sysplugins/smarty_internal_compile_call.php
Smarty-3.1.14/libs/sysplugins/smarty_internal_compile_private_object_block_function.php
Smarty-3.1.14/libs/sysplugins/smarty_internal_get_include_path.php
Smarty-3.1.14/libs/sysplugins/smarty_internal_compile_nocache.php
Smarty-3.1.14/libs/sysplugins/smarty_internal_write_file.php
Smarty-3.1.14/libs/sysplugins/smarty_internal_compile_debug.php
Smarty-3.1.14/libs/sysplugins/smarty_internal_compile_private_block_plugin.php
Smarty-3.1.14/libs/sysplugins/smarty_internal_function_call_handler.php
Smarty-3.1.14/libs/sysplugins/smarty_cacheresource_custom.php
Smarty-3.1.14/libs/sysplugins/smarty_internal_utility.php
Smarty-3.1.14/libs/sysplugins/smarty_internal_templateparser.php
Smarty-3.1.14/libs/sysplugins/smarty_internal_compile_extends.php
Smarty-3.1.14/libs/sysplugins/smarty_internal_compile_private_registered_block.php
Smarty-3.1.14/libs/sysplugins/smarty_internal_parsetree.php
Smarty-3.1.14/libs/plugins/
Smarty-3.1.14/libs/plugins/modifiercompiler.from_charset.php
Smarty-3.1.14/libs/plugins/modifiercompiler.to_charset.php
Smarty-3.1.14/libs/plugins/modifiercompiler.unescape.php
Smarty-3.1.14/libs/plugins/outputfilter.trimwhitespace.php
Smarty-3.1.14/libs/plugins/modifiercompiler.escape.php
Smarty-3.1.14/libs/plugins/function.mailto.php
Smarty-3.1.14/libs/plugins/modifiercompiler.cat.php
Smarty-3.1.14/libs/plugins/function.html_checkboxes.php
Smarty-3.1.14/libs/plugins/function.counter.php
Smarty-3.1.14/libs/plugins/modifier.replace.php
Smarty-3.1.14/libs/plugins/modifier.debug_print_var.php
Smarty-3.1.14/libs/plugins/modifiercompiler.count_paragraphs.php
Smarty-3.1.14/libs/plugins/modifier.date_format.php
Smarty-3.1.14/libs/plugins/modifiercompiler.upper.php
Smarty-3.1.14/libs/plugins/function.fetch.php
Smarty-3.1.14/libs/plugins/modifiercompiler.strip_tags.php
Smarty-3.1.14/libs/plugins/modifiercompiler.count_sentences.php
Smarty-3.1.14/libs/plugins/modifier.truncate.php
Smarty-3.1.14/libs/plugins/function.cycle.php
Smarty-3.1.14/libs/plugins/modifier.regex_replace.php
Smarty-3.1.14/libs/plugins/function.html_image.php
Smarty-3.1.14/libs/plugins/function.html_table.php
Smarty-3.1.14/libs/plugins/modifiercompiler.lower.php
Smarty-3.1.14/libs/plugins/modifier.capitalize.php
Smarty-3.1.14/libs/plugins/modifiercompiler.noprint.php
Smarty-3.1.14/libs/plugins/modifiercompiler.count_characters.php
Smarty-3.1.14/libs/plugins/function.html_options.php
Smarty-3.1.14/libs/plugins/block.textformat.php
Smarty-3.1.14/libs/plugins/shared.literal_compiler_param.php
Smarty-3.1.14/libs/plugins/modifier.spacify.php
Smarty-3.1.14/libs/plugins/shared.mb_wordwrap.php
Smarty-3.1.14/libs/plugins/shared.make_timestamp.php
Smarty-3.1.14/libs/plugins/modifiercompiler.count_words.php
Smarty-3.1.14/libs/plugins/modifiercompiler.indent.php
Smarty-3.1.14/libs/plugins/shared.mb_str_replace.php
Smarty-3.1.14/libs/plugins/function.html_select_date.php
Smarty-3.1.14/libs/plugins/shared.escape_special_chars.php
Smarty-3.1.14/libs/plugins/modifiercompiler.wordwrap.php
Smarty-3.1.14/libs/plugins/function.html_select_time.php
Smarty-3.1.14/libs/plugins/modifiercompiler.string_format.php
Smarty-3.1.14/libs/plugins/function.html_radios.php
Smarty-3.1.14/libs/plugins/shared.mb_unicode.php
Smarty-3.1.14/libs/plugins/modifier.escape.php
Smarty-3.1.14/libs/plugins/function.math.php
Smarty-3.1.14/libs/plugins/modifiercompiler.strip.php
Smarty-3.1.14/libs/plugins/modifiercompiler.default.php
Smarty-3.1.14/libs/plugins/variablefilter.htmlspecialchars.php
Smarty-3.1.14/libs/Smarty.class.php
Smarty-3.1.14/libs/SmartyBC.class.php
Smarty-3.1.14/README
Smarty-3.1.14/SMARTY_3.1_NOTES.txt

3. 好きな場所にlibsフォルダを移動します

展開が終わったら、展開されたファイルの中にあるlibsディレクトリを適当な
場所に移動すればインストール官僚です。

いかでは、”/usr/local/lib/Smarty”に配置してます。

# mv Smarty-3.1.14/libs/ /usr/local/lib/Smarty

pearをインストールする

さくらvpsでは初期状態では、pearがインストールされてません。

そこで、pearをインストールします。

# wget http://pear.php.net/go-pear.phar
--2013-09-29 00:44:53--  http://pear.php.net/go-pear.phar
Resolving pear.php.net... 5.77.39.20
Connecting to pear.php.net|5.77.39.20|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 4082712 (3.9M) [application/octet-stream]
Saving to: `go-pear.phar'

100%[===============================================================>] 4,082,712   1.01M/s   in 3.9s

2013-09-29 00:44:58 (1.01 MB/s) - `go-pear.phar' saved [4082712/4082712]

# ls
go-pear.phar
# php go-pear.phar

Below is a suggested file layout for your new PEAR installation.  To
change individual locations, type the number in front of the
directory.  Type 'all' to change all of them or simply press Enter to
accept these locations.

 1. Installation base ($prefix)                   : /usr
 2. Temporary directory for processing            : /tmp/pear/install
 3. Temporary directory for downloads             : /tmp/pear/install
 4. Binaries directory                            : /usr/bin
 5. PHP code directory ($php_dir)                 : /usr/share/pear
 6. Documentation directory                       : /usr/docs
 7. Data directory                                : /usr/data
 8. User-modifiable configuration files directory : /usr/cfg
 9. Public Web Files directory                    : /usr/www
10. Tests directory                               : /usr/tests
11. Name of configuration file                    : /etc/pear.conf

1-11, 'all' or Enter to continue:
Beginning install...
PHP Warning:  date(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'Asia/Tokyo' for 'JST/9.0/no DST' instead in phar:///root/go-pear.phar/PEAR/Registry.php on line 1012
PHP Warning:  date(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'Asia/Tokyo' for 'JST/9.0/no DST' instead in phar:///root/go-pear.phar/PEAR/Registry.php on line 1012
PHP Warning:  date(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'Asia/Tokyo' for 'JST/9.0/no DST' instead in phar:///root/go-pear.phar/PEAR/Registry.php on line 1012
PHP Warning:  date(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'Asia/Tokyo' for 'JST/9.0/no DST' instead in phar:///root/go-pear.phar/PEAR/Registry.php on line 1012
Configuration written to /etc/pear.conf...
Initialized registry...
Preparing to install...
installing phar:///root/go-pear.phar/PEAR/go-pear-tarballs/Archive_Tar-1.3.11.tar...
installing phar:///root/go-pear.phar/PEAR/go-pear-tarballs/Console_Getopt-1.3.1.tar...
installing phar:///root/go-pear.phar/PEAR/go-pear-tarballs/PEAR-1.9.4.tar...
installing phar:///root/go-pear.phar/PEAR/go-pear-tarballs/Structures_Graph-1.0.4.tar...
installing phar:///root/go-pear.phar/PEAR/go-pear-tarballs/XML_Util-1.2.1.tar...
install ok: channel://pear.php.net/Archive_Tar-1.3.11
install ok: channel://pear.php.net/Console_Getopt-1.3.1
install ok: channel://pear.php.net/Structures_Graph-1.0.4
install ok: channel://pear.php.net/XML_Util-1.2.1
install ok: channel://pear.php.net/PEAR-1.9.4
PEAR: Optional feature webinstaller available (PEAR's web-based installer)
PEAR: Optional feature gtkinstaller available (PEAR's PHP-GTK-based installer)
PEAR: Optional feature gtk2installer available (PEAR's PHP-GTK2-based installer)
PEAR: To install optional features use "pear install pear/PEAR#featurename"

The 'pear' command is now at your service at /usr/bin/pear

** The 'pear' command is not currently in your PATH, so you need to
** use '/usr/bin/pear' until you have added
** '/usr/bin' to your PATH environment variable.

Run it without parameters to see the available actions, try 'pear list'
to see what packages are installed, or 'pear help' for help.

For more information about PEAR, see:

http://pear.php.net/faq.php


http://pear.php.net/manual/

Thanks for using go-pear!

ftpクライアントのインストール

さくらVPSの初期状態では、ftpクライアントがインストールされてないので、

インストールしましょう。

# yum -y install ftp
Loaded plugins: fastestmirror, security
Loading mirror speeds from cached hostfile
epel/metalink                                                                     | 6.6 kB     00:00
 * base: ftp.iij.ad.jp
 * epel: ftp.kddilabs.jp
 * extras: ftp.iij.ad.jp
 * updates: ftp.iij.ad.jp
base                                                                              | 3.7 kB     00:00
extras                                                                            | 3.4 kB     00:00
updates                                                                           | 3.4 kB     00:00
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package ftp.x86_64 0:0.17-53.el6 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

=========================================================================================================
 Package              Arch                    Version                        Repository             Size
=========================================================================================================
Installing:
 ftp                  x86_64                  0.17-53.el6                    base                   58 k

Transaction Summary
=========================================================================================================
Install       1 Package(s)

Total download size: 58 k
Installed size: 95 k
Downloading Packages:
ftp-0.17-53.el6.x86_64.rpm                                                        |  58 kB     00:00
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
  Installing : ftp-0.17-53.el6.x86_64                                                                1/1
  Verifying  : ftp-0.17-53.el6.x86_64                                                                1/1

Installed:
  ftp.x86_64 0:0.17-53.el6

Complete!

これで、以下のようにしてftpが使用できます。

$ ftp example.com

vsftpdにrootでログインする

vsftpdをインストールしただけでは、rootユーザでログインすることができなかった。

そこで、以下の2つのファイルを編集することでrootユーザでもログインすることが
できるようになりました。

1. “/etc/vsftpd/user_list”を編集する

“/etc/vsftpd/user_list”にある”root”の行頭に”#”をつけて
コメントアウトします。

修正前

# vsftpd userlist
# If userlist_deny=NO, only allow users in this file
# If userlist_deny=YES (default), never allow users in this file, and
# do not even prompt for a password.
# Note that the default vsftpd pam config also checks /etc/vsftpd/ftpusers
# for users that are denied.
root
bin
daemon
adm
lp
sync
shutdown
halt
mail
news
uucp
operator
games
nobody

修正後

# vsftpd userlist
# If userlist_deny=NO, only allow users in this file
# If userlist_deny=YES (default), never allow users in this file, and
# do not even prompt for a password.
# Note that the default vsftpd pam config also checks /etc/vsftpd/ftpusers
# for users that are denied.
#root
bin
daemon
adm
lp
sync
shutdown
halt
mail
news
uucp
operator
games
nobody

2. “/etc/vsftpd/ftpusers”を編集する

同じく、”/etc/vsftpd/ftpusers”の”root”もコメントアウトします。

修正前

# Users that are not allowed to login via ftp
root
bin
daemon
adm
lp
sync
shutdown
halt
mail
news
uucp
operator
games
nobody

修正後

# Users that are not allowed to login via ftp
# root
bin
daemon
adm
lp
sync
shutdown
halt
mail
news
uucp
operator
games
nobody

3. vsftpdを再起動する

vsftpdを以下のようにして再起動します。
※再起動しなくても有効になるっぽいです。もし有効にならなかった場合は一応ためしてみるのもいいかもしれません。

# /etc/init.d/vsftpd restart
Shutting down vsftpd:                                      [  OK  ]
Starting vsftpd for vsftpd:                                [  OK  ]

rootのパスワードを設定する方法

$ mysql -uroot
Welcome to the MySQL monitor.  Commands end with ; or g.
Your MySQL connection id is 8
Server version: 5.1.69 Source distribution

Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or 'h' for help. Type 'c' to clear the current input statement.

mysql> set password for root@localhost=password('hogepass');
Query OK, 0 rows affected (0.00 sec)

mysql> Bye
$ mysql -uroot
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)

データベースをコピーする方法

mysqldumpコマンドとmysqlコマンドを使えば簡単に、データベースのコピーができます。

対象のDB(ここではhogedb)をバックアップします

$ mysqldump hogedb -uhogeuser -phogepass > backup.db

バックアップしたdbを別のDB名(ここではfoodb)としてリストアします

$ mysql foodb -uhogeuser -phogepass < backup.db

このときfoodbは作成済みである必要があります。