MySQLのSelect文で特定の文字列の場所を見つけると同時に分割する関数でsubstring_indexというのが便利だったのでメモ。indexofとsubstringの両方が合わさったもの。
substring_index("www.google.com",".","2)
1つ目と2つ目の引数は明らかなので割愛。3つ目の引数がポイント。
正の数:分割された文字列の何番目かを左からから指す
負の数:分割された文字列の何番目かを右からから指す
http://www.w3resource.com/mysql/string-functions/mysql-substring_index-function.php
2015年7月30日木曜日
2015年6月17日水曜日
MySQLについてくるautomysqlbackupの使い方
MySQLにはバックアップ専用にautomysqlbackupがついてくるので、ちょっと使い方についてメモ書き。
https://serverpilot.io/community/articles/how-to-back-up-mysql-databases-with-automysqlbackup.html
- sudo apt-get install automysqlbackup でインストール
- /var/lib/automysqlbackup にバックアップが毎日作られるが、スクリプト中で保存先は指定できる。
※ BACKUPDIRとDBNAMESぐらいかな、変更したのは。。
https://serverpilot.io/community/articles/how-to-back-up-mysql-databases-with-automysqlbackup.html
MySQL 5.1 をUbuntu 12.04にインストールする方法
MySQL5.1をUbuntu12.04にインストールしようと思ったら、apt-getでは5.5がインストールされてしまうので、ソースからMySQL5.1をインストールするのに以下を参考にした。
シェルスクリプトでもコマンドラインからでもOK。
#!/bin/bash
set -e
cd ~/
wget http://downloads.mysql.com/archives/mysql-5.1/mysql-5.1.65.tar.gz
tar -zxf mysql-5.1.65.tar.gz
cd mysql-5.1.65
./configure '--prefix=/usr' '--exec-prefix=/usr' '--libexecdir=/usr/sbin' '--datadir=/usr/share' '--localstatedir=/var/lib/mysql' '--includedir=/usr/include' '--infodir=/usr/share/info' '--mandir=/usr/share/man' '--with-system-type=debian-linux-gnu' '--enable-shared' '--enable-static' '--enable-thread-safe-client' '--enable-assembler' '--enable-local-infile' '--with-fast-mutexes' '--with-big-tables' '--with-unix-socket-path=/var/run/mysqld/mysqld.sock' '--with-mysqld-user=mysql' '--with-libwrap' '--without-readline' '--with-ssl' '--without-docs' '--with-extra-charsets=all' '--with-plugins=max' '--with-embedded-server' '--with-embedded-privilege-control'
make
sudo make install
参考
http://askubuntu.com/questions/125686/failed-to-spawn-mysql-main-process-unable-to-execute-no-such-file-or-director
シェルスクリプトでもコマンドラインからでもOK。
#!/bin/bash
set -e
cd ~/
wget http://downloads.mysql.com/archives/mysql-5.1/mysql-5.1.65.tar.gz
tar -zxf mysql-5.1.65.tar.gz
cd mysql-5.1.65
./configure '--prefix=/usr' '--exec-prefix=/usr' '--libexecdir=/usr/sbin' '--datadir=/usr/share' '--localstatedir=/var/lib/mysql' '--includedir=/usr/include' '--infodir=/usr/share/info' '--mandir=/usr/share/man' '--with-system-type=debian-linux-gnu' '--enable-shared' '--enable-static' '--enable-thread-safe-client' '--enable-assembler' '--enable-local-infile' '--with-fast-mutexes' '--with-big-tables' '--with-unix-socket-path=/var/run/mysqld/mysqld.sock' '--with-mysqld-user=mysql' '--with-libwrap' '--without-readline' '--with-ssl' '--without-docs' '--with-extra-charsets=all' '--with-plugins=max' '--with-embedded-server' '--with-embedded-privilege-control'
make
sudo make install
参考
http://askubuntu.com/questions/125686/failed-to-spawn-mysql-main-process-unable-to-execute-no-such-file-or-director
2015年5月15日金曜日
HTML5でログインフォームの書き方
HTML5でログインフォームの書き方
HTML
<section class="loginform cf">
<form name="login" action="/path" method="POST" accept-charset="utf-8">
<ul>
<li><label for="usermail">Login Name</label>
<input type="text" name="loginName" placeholder="login name" required></li>
<li><label for="password">Password</label>
<input type="password" name="password" placeholder="password" required></li>
<li><input type="submit" value="Login"></li>
</ul>
</form>
</section>
CSSは参考リンク参照
参考
http://www.hongkiat.com/blog/html5-loginpage/
JavaScriptでhtmlのDOMエレメントのクラス名を得るには?
JavaScriptでhtmlのDOMエレメントのクラス名を得るには?
document.getElementById('divId').className.split(/\s+/);
参考
http://stackoverflow.com/questions/1227286/get-class-list-for-element-with-jquery
document.getElementById('divId').className.split(/\s+/);
参考
http://stackoverflow.com/questions/1227286/get-class-list-for-element-with-jquery
MySQL5.5をUbuntuから完全に消去する方法
MySQL5.5をUbuntuからアンインストールしたかったので、やり方を調べてみた。
http://stackoverflow.com/questions/10853004/removing-mysql-5-5-completely
http://askubuntu.com/questions/125686/failed-to-spawn-mysql-main-process-unable-to-execute-no-such-file-or-director
sudo deluser mysql
sudo delgroup mysql
sudo service mysql stop #or mysqld
sudo killall -9 mysql
sudo killall -9 mysqld
sudo apt-get remove --purge mysql-server mysql-client mysql-common
sudo apt-get autoremove
sudo apt-get autoclean
sudo deluser mysql
sudo rm -rf /var/lib/mysql
sudo apt-get purge mysql-server-core-5.5
sudo apt-get purge mysql-client-core-5.5
参考http://stackoverflow.com/questions/10853004/removing-mysql-5-5-completely
http://askubuntu.com/questions/125686/failed-to-spawn-mysql-main-process-unable-to-execute-no-such-file-or-director
Ubuntuで新規ユーザーにsudo権限を与える方法
Ubuntuで新規ユーザーにsudo権限を与える方法
1.% sudo adduser (username)
2.% sudo gpasswd -a (username) sudo
参考
https://ueponx.wordpress.com/2013/09/23/ubuntu%E3%81%AB%E3%81%A6%E6%96%B0%E8%A6%8F%E3%83%A6%E3%83%BC%E3%82%B6%E3%81%ABsudo%E3%81%AE%E6%A8%A9%E9%99%90%E3%82%92%E3%81%A4%E3%81%91%E3%82%8B/
1.% sudo adduser (username)
2.% sudo gpasswd -a (username) sudo
3.% logout
参考
https://ueponx.wordpress.com/2013/09/23/ubuntu%E3%81%AB%E3%81%A6%E6%96%B0%E8%A6%8F%E3%83%A6%E3%83%BC%E3%82%B6%E3%81%ABsudo%E3%81%AE%E6%A8%A9%E9%99%90%E3%82%92%E3%81%A4%E3%81%91%E3%82%8B/
登録:
投稿 (Atom)