Sunday, September 13, 2015
Thursday, June 25, 2015
Reset MYSQL Password
MySQL - Resetting a lost MySQL root password
- Article ID: 405
- Last updated on August 31, 2012
- Authored by: Rackspace Support
The MySQL root password allows full access to the MySQL database and allows for all actions to be undertaken including creating new users, new databases, setting access rules and so on.
Losing one can be a difficult issue to encounter. Luckily, resetting the root password is easy as long as you have sudo access to the Server.
Contents |
Not the Server root user
A common issue is confusing the Server root user with the MySQL root user.
The Server root user is the server's main user. The MySQL root user has complete control over MySQL only. The two 'root' users are not connected in any way.
Stop MySQL
The first thing to do is stop MySQL. If you are using Ubuntu or Debian the command is as follows:
sudo /etc/init.d/mysql stop
For CentOS, Fedora, and RHEL the command is:
sudo /etc/init.d/mysqld stop
Safe mode
Next we need to start MySQL in safe mode - that is to say, we will start MySQL but skip the user privileges table. Again, note that you will need to have sudo access for these commands so you don't need to worry about any user being able to reset the MySQL root password:
sudo mysqld_safe --skip-grant-tables &
Note: The ampersand (&) at the end of the command is required.
Login
All we need to do now is to log into MySQL and set the password.
mysql -u root
Note: No password is required at this stage as when we started MySQL we skipped the user privileges table.
Next, instruct MySQL which database to use:
use mysql;
Reset Password
Enter the new password for the root user as follows:
update user set password=PASSWORD("mynewpassword") where User='root';
and finally, flush the privileges:
flush privileges;
Restart
Now the password has been reset, we need to restart MySQL by logging out:
quit
and simply stopping and starting MySQL.
On Ubuntu and Debian:
sudo /etc/init.d/mysql stop ... sudo /etc/init.d/mysql start
On CentOS and Fedora and RHEL:
sudo /etc/init.d/mysqld stop ... sudo /etc/init.d/mysql start
Login
Test the new password by logging in:
mysql -u root -p
You will be prompted for your new password.
Wednesday, March 25, 2015
Masalah Server Ubuntu x Leh boot lepas Powertrip atau Force Shutdown
Error : Target filesystem doesn't have /sbin/init
Error ini berkemungkinan berlaku disebabkan oleh kerosakan pada file-system yang mana rosak disebabkan oleh cara shutdown yang tidak betul (force) atau berlakunya gangguan bekalan elektrik dimana tiada ups untuk membuat prosedur shutdown dengan betul.
Insyallah boleh cuba cara ini untuk membaiki file-system tersebut.
1. Dapatkan bootable iso di http://distrowatch.com/table.php? mengikut OS yang berkenaan.
a. sekiranya physical server
i. Burn pada usb agar boleh boot guna USB tersebut.
ii.Boleh gunakan software berikut untuk burn dalam usb http://unetbootin.sourceforge.net/
iii. Boot server untuk load OS dari USB
Step ini yang aku tunjuk.
b. Virtual Server.
i. Boleh boot terus dari ISO yang telah didownload.
2. Run command dalam terminal
Pilih Try Ubuntu
Cari Terminal
Taip command kat bawah ni.
command yg sama mcm chkdsk dalam Windows. Kita nak check dan repair filesystems.
Dah siap dah ....
3. Cabut atau disconnet USB/ISO
4. Reboot Server
Kan dah boleh reboot server korang.
Alhamdulillah berbuat baiklah sesama manusia. Insyallah Allah akan balas budi korang.
Telah di uji di Server Ubuntu.
mount: mounting /dev on /root/dev failed: No such file or directory
mount: mounting /sys on /root/sys failed: No such file or directory
mount: mounting /proc on /root/proc failed: No such file or directory
Target filesystem doesn't have /sbin/init
No init found. Try passing init= bootarg
(and then something about initramfs)
Error ini berkemungkinan berlaku disebabkan oleh kerosakan pada file-system yang mana rosak disebabkan oleh cara shutdown yang tidak betul (force) atau berlakunya gangguan bekalan elektrik dimana tiada ups untuk membuat prosedur shutdown dengan betul.
Insyallah boleh cuba cara ini untuk membaiki file-system tersebut.
1. Dapatkan bootable iso di http://distrowatch.com/table.php? mengikut OS yang berkenaan.
a. sekiranya physical server
i. Burn pada usb agar boleh boot guna USB tersebut.
ii.Boleh gunakan software berikut untuk burn dalam usb http://unetbootin.sourceforge.net/
iii. Boot server untuk load OS dari USB
Step ini yang aku tunjuk.
b. Virtual Server.
i. Boleh boot terus dari ISO yang telah didownload.
2. Run command dalam terminal
Pilih Try Ubuntu
Cari Terminal
Taip command kat bawah ni.
sudo e2fsck -f -y -v /dev/sda1
sudo reboot
command yg sama mcm chkdsk dalam Windows. Kita nak check dan repair filesystems.
Dah siap dah ....
3. Cabut atau disconnet USB/ISO
4. Reboot Server
Kan dah boleh reboot server korang.
Alhamdulillah berbuat baiklah sesama manusia. Insyallah Allah akan balas budi korang.
Telah di uji di Server Ubuntu.
Wednesday, January 21, 2015
Memasang OwnCloud 7.0.4 dengan Nginx, MariaDB dan PHP-FPM dalam Ubuntu
Masuk ke server Ubuntu (Aku guna Ubuntu 14.0.4 dan masa install aku hanya pilih install ssh-server je). Lepas tu guna putty masuk ke server tu. Biasanya ini best practices cara aku klu korang nak start.
apt-get update
apt-get upgrade
Install la MariaDB database yang akan femes masa kini. Tapi kalau korang nak guna yang lain kena la cari kat tempat lain ye!
sudo apt-get install mariadb-server
Guna skrip dibawah klu korang nak secure db korang. Tp aku recommend buat la.
mysql_secure_installation
Jawab soklan ikut macamana korang nak securitykan DB korang tu. Tak faham tanya pakcik google.
- Set root password? [Y/n] y
- Remove anonymous users? [Y/n] y
- Disallow root login remotely? [Y/n] y
- Remove test database and access to it? [Y/n] y
- Reload privilege tables now? [Y/n] y
Masuk ke MariaDB sebagai root dan korang create user baru untuk database Owncloud tu
mysql -u root -p
Enter password:
MariaDB [(none)]> CREATE DATABASE owncloud;
MariaDB [(none)]> GRANT ALL ON owncloud.* to ownclouduser@localhost identified by 'YOURPASSWORD';
MariaDB [(none)]> FLUSH PRIVILEGES;
MariaDB [(none)]> \q
Install Nginx web server, PHP5-FPM dan pakej yang diperlukan ... just cut and paste je .. dulu penerangan kenapa kena install korang google la ...
sudo apt-get install nginx php5-fpm php5-common php5-cli php5-json php5-mysql php5-curl php5-intl php5-mcrypt php5-memcache php5-gd
Dah siap boleh la g download pakej Installer ownCLoud dari website dia.Version aku 7.0.4
cd /usr/share/
sudo wget https://download.owncloud.org/community/owncloud-7.0.4.tar.bz2
sudo tar xvfj owncloud-7.0.4.tar.bz2
sudo rm owncloud-7.0.4.tar.bz2
sudo chown -R www-data:www-data owncloud/
Korang kena generate sijil ssl dia dan adjust sket nginx config
sudo mkdir /etc/nginx/ssl
sudo openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout /etc/nginx/ssl/owncloud.key -out /etc/nginx/ssl/owncloud.crt
Akan keluar satu scripts so follow Me la ...
Generating a 2048 bit RSA private key
..+++
....................+++
writing new private key to '/etc/nginx/ssl/owncloud.key'
-----
You are about to be asked to enter information that will be incorporated
into your certificate request.
What you are about to enter is what is called a Distinguished Name or a DN.
There are quite a few fields but you can leave some blank
For some fields there will be a default value,
If you enter '.', the field will be left blank.
-----
Country Name (2 letter code) [AU]:MY
State or Province Name (full name) [Some-State]:
Locality Name (eg, city) []:
Organization Name (eg, company) [Internet Widgits Pty Ltd]:
Organizational Unit Name (eg, section) []:
Common Name (e.g. server FQDN or YOUR name) []:
Email Address []:
Edit atau create virtual block dalam nginx
sudo vi /etc/nginx/sites-available/default
Masukan script ni la bro !.
upstream php-handler {
#server 127.0.0.1:9000;
server unix:/var/run/php5-fpm.sock;
}
server {
listen 80;
server_name 10.0.0.11;
return 301 https://$server_name$request_uri; # enforce https
}
server {
listen 443 ssl;
server_name 10.0.0.11;
ssl_certificate /etc/nginx/ssl/owncloud.crt;
ssl_certificate_key /etc/nginx/ssl/owncloud.key;
# Path to the root of your installation
root /usr/share/owncloud;
client_max_body_size 10G; # set max upload size
fastcgi_buffers 64 4K;
rewrite ^/caldav(.*)$ /remote.php/caldav$1 redirect;
rewrite ^/carddav(.*)$ /remote.php/carddav$1 redirect;
rewrite ^/webdav(.*)$ /remote.php/webdav$1 redirect;
index index.php;
error_page 403 /core/templates/403.php;
error_page 404 /core/templates/404.php;
location = /robots.txt {
allow all;
log_not_found off;
access_log off;
}
location ~ ^/(?:\.htaccess|data|config|db_structure\.xml|README) {
deny all;
}
location / {
# The following 2 rules are only needed with webfinger
rewrite ^/.well-known/host-meta /public.php?service=host-meta last;
rewrite ^/.well-known/host-meta.json /public.php?service=host-meta-json last;
rewrite ^/.well-known/carddav /remote.php/carddav/ redirect;
rewrite ^/.well-known/caldav /remote.php/caldav/ redirect;
rewrite ^(/core/doc/[^\/]+/)$ $1/index.html;
try_files $uri $uri/ index.php;
}
location ~ \.php(?:$|/) {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param HTTPS on;
fastcgi_pass php-handler;
}
# Optional: set long EXPIRES header on static assets
location ~* \.(?:jpg|jpeg|gif|bmp|ico|png|css|js|swf)$ {
expires 30d;
# Optional: Don't log access to assets
access_log off;
}
}
Enable kan script tadi ...
sudo ln -s /etc/nginx/sites-available/default /etc/nginx/sites-enabled/default/
Editkan php-fpm config fail.
sudo vi /etc/php5/fpm/pool.d/www.conf
Masukan atau periksa value
listen = /var/www/php5-fpm.sock
listen.owner = www-data
listen.group = www-data
Restart Nginx and PHP-FPM.
sudo service nginx restart
sudo service php5-fpm restart
sudo service php5-fpm restart
Monday, October 6, 2014
Upgrade Redmine 1.3 to Redmine 2.5 on Ubuntu 12.04
This is my way to upgrade Redmine 1.3 to Redmine 2.5 .For the past 2 week , i has been tried to seek the best way to upgrade my Redmine 1.3 without upgrading my Ubuntu OS.
I'm NOT Redmine atau Ubuntu JEDI ... hehehehe , So please forgive me for any mistakes that made by my own. Hopefully with a feedback, i can make the installation notes more better and clearer.
Lets Start:
Get into existing Redmine folder and move to backup folder.
cd /usr/share
ls
sudo mv redmine old-redmine
Now we’re going to download the latest version of Redmine from RubyForge: http://www.redmine.org/projects/redmine/wiki/Download. When i do this, the release is redmine-2.5.2.tar.gz. We need to extract and rename it to redmine folder and give correct permission. Make sure that a particular file is set to www-data as owner. This is because Passenger runs as the user that owns this file
sudo wget http://www.redmine.org/releases/redmine-2.5.2.tar.gz
sudo tar xvfz redmine-2.5.2.tar.gz
sudo mv redmine-2.5.2 redmine
sudo chown -R root:root /usr/share/redmine
sudo chown www-data /usr/share/redmine/config/environment.rb
Update a symbolic link from the main website home back to our actual Redmine application directory.
sudo mv /var/www/redmine /var/www/0ld-redmine
sudo ln -s /usr/share/redmine/public /var/www/redmine
Now we need to configure DB and make sure existing DB name is same in the new config files:
sudo cp redmine/config/database.yml.example redmine/config/database.yml
sudo nano redmine/config/database.yml
production:
adapter: mysql2
database: redmine (*same with old DB name*)
host: localhost
username: redmine
password: my_password (*same with old DB name*)
encoding: utf8
Before proceed redmine need to install ruby1.1.9-full and add all required libraries.
I preferred to use RMagick to enable Gantt export to png image.
sudo apt-get install ruby1.9.1-full libmagickcore-dev libmagickwand-dev libmysqlclient-dev
We need to install bundle. Bundle is using to install Ruby Gems that needed by Redmine.
sudo gem install bundler
Change to redmine folder and run to install Gems
cd redmine
sudo bundle install --without development test postgresql sqlite
Configure Redmine:
There are question before the script finish configure, we need to choose our languange.
Type the code accordingly to your country or preferable languange.
sudo rake generate_secret_token
sudo RAILS_ENV=production rake db:migrate
sudo RAILS_ENV=production rake redmine:load_default_data
Some directory,we need to configure correct directory permissions:
sudo mkdir public/plugin_assets
sudo chown -R www-data:www-data files log tmp public/plugin_assets
sudo chmod -R 755 files log tmp public/plugin_assets
Now we can test Redmine:
sudo ruby script/rails server webrick -e production
Enter your webaddress:http://ipaddress:3000 you should see the new version Redmine homepage.
Now configure Passenger to make sure it launches when Apache runs.
I'm NOT Redmine atau Ubuntu JEDI ... hehehehe , So please forgive me for any mistakes that made by my own. Hopefully with a feedback, i can make the installation notes more better and clearer.
Preliminary :
Check version Ubuntu
lsb_release -a
Check which ruby:
which ruby
/usr/bin/ruby
ls -l /usr/bin/ruby
lrwxrwxrwx 1 root root 22 Sep 26 16:05 /usr/bin/ruby -> /etc/alternatives/ruby
ls -l /etc/alternatives/ruby
lrwxrwxrwx 1 root root 16 2011-10-17 21:20 /usr/local/bin/ruby -> /usr/bin/ruby1.8
Change to ruby1.9
sudo update-alternatives --config ruby
There are 2 choices for the alternative ruby (providing /usr/bin/ruby).
Selection Path Priority Status
------------------------------------------------------------
* 0 /usr/bin/ruby1.8 50 auto mode
1 /usr/bin/ruby1.8 50 manual mode
2 /usr/bin/ruby1.9.1 10 manual mode
Press enter to keep the current choice[*], or type selection number: 2
update-alternatives: using /usr/bin/ruby1.9.1 to provide /usr/bin/ruby (ruby) in manual mode.
ruby --version
ruby 1.9.2p290 (2011-07-09 revision 32553) [x86_64-linux]
ls -l /etc/alternatives/ruby
lrwxrwxrwx 1 root root 18 2011-12-30 17:35 /etc/alternatives/ruby -> /usr/bin/ruby1.9.1
We need to configure Gems also:
sudo update-alternatives --config gem
There are 2 choices for the alternative gem (providing /usr/bin/gem).
Selection Path Priority Status
------------------------------------------------------------
* 0 /usr/bin/gem1.8 180 auto mode
1 /usr/bin/gem1.8 180 manual mode
2 /usr/bin/gem1.9.1 10 manual mode
Press enter to keep the current choice[*], or type selection number: 2
update-alternatives: using /usr/bin/gem1.9.1 to provide /usr/bin/gem (gem) in manual mode.
Install & Configure Passenger:
sudo gem install passenger
Before we can install the Passenger module, we need some additional software:
sudo apt-get install libcurl4-openssl-dev libssl-dev apache2-prefork-dev libapr1-dev libaprutil1-dev
Now we are set to install the Passenger module for Apache:
sudo passenger-install-apache2-module
Passenger will run & compile the source code into the module for Apache.
When compilation almost finish you need to copy some configuration from the running scripts:
Please edit your Apache configuration file, and add these lines:
LoadModule passenger_module /var/lib/gems/1.9.1/gems/passenger-4.0.53/buildout/apache2/mod_passenger.so
PassengerRoot /var/lib/gems/1.9.1/gems/passenger-4.0.53
PassengerDefaultRuby /usr/bin/ruby1.9.1
After you restart Apache, you are ready to deploy any number of web
applications on Apache, with a minimum amount of configuration!
Backup old loader
sudo mv /etc/apache2/mods-enabled/passenger.load /home/admindesa(myhome folder)/
Now use nano or your favourite editor to create the loader:
sudo vi /etc/apache2/mods-available/passenger.load
#LoadModule passenger_module /usr/lib/apache2/modules/mod_passenger.so
LoadModule passenger_module /var/lib/gems/1.9.1/gems/passenger-4.0.53/buildout/apache2/mod_passenger.so
Then make the module enabled:sudo ln -s /etc/apache2/mods-available/passenger.load /etc/apache2/mods-enabled/passenger.load
Backup Old Virtual
sudo mv /etc/apache2/sites-available/default /home/admindesa/
Configure Passenger in Virtual Hosts
vi /etc/apache2/mods-available/passenger.conf
Edit a configuration file for Passenger
PassengerDefaultUser www-data
PassengerRoot /var/lib/gems/1.9.1/gems/passenger-4.0.53
PassengerDefaultRuby /usr/bin/ruby1.9.1
# PassengerRoot /usr
# PassengerRuby /usr/bin/ruby
Reconfigure Virtual Hosts
sudo mv /etc/apache2/sites-available/default /home/admindesa/
sudo vi /etc/apache2/sites-available/default
ServerName my_domain.com
DocumentRoot /var/www/redmine
ServerAdmin user@example.com
LogLevel warn
ErrorLog /var/log/apache2/redmine_error
CustomLog /var/log/apache2/redmine_access combined
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
RailsBaseURI /redmine
PassengerResolveSymlinksInDocumentRoot on
Tell Apache how to configure Passenger:
sudo nano /etc/apache2/apache2.conf
Add the following line at the end of the file:
Include /etc/apache2/mods-available/passenger.conf
Finally, enable the site:
sudo mv /etc/apache2/sites-enabled/000-default /home/admindesa/
sudo ln -s /etc/apache2/sites-available/default /etc/apache2/sites-enabled/000-default
Make sure the Passenger module is enabled:
sudo a2enmod passenger
And, restart Apache:
sudo service apache2 restart
If everything went well, then you should be able to see Redmine in your browser:
When compilation almost finish you need to copy some configuration from the running scripts:
Saturday, October 4, 2014
How to check our Ubuntu version
Some time we need to determine which version our Ubuntu running :
Before upgrade version
When we need to update application
Before upgrade version
When we need to update application
lsb_release -a
Friday, October 3, 2014
Rename Symlink
Pada satu ketika keperluan untuk rename symlink asal kpada yang baru diperlukan. Ini bertujuan untuk mengunakan nama symlink sediaada kepada :
- version baru
- copy folder baru
- folder apps yang nak guna nama symlink yang telah digunakan
- housekeeping
sudo mv redmine(old symlink) old-redmine(new symlink)
Subscribe to:
Posts (Atom)