Cannot configure secure MAC addresses

Symptom

Cannot configure secure MAC addresses.

[Device-GigabitEthernet1/0/1] port-security mac-address security 1-1-2 vlan 1
Error: Security MAC address configuration failed. 
Error:Can not operate security MAC address for current port mode is not autoLearn!

Analysis

Secure MAC address can only be configured on ports operating in autoLearn mode.

Solution

Set the port security mode to autoLearn.

[Device-GigabitEthernet1/0/1] undo port-security port-mode
[Device-GigabitEthernet1/0/1] port-security max-mac-count 64
[Device-GigabitEthernet1/0/1] port-security port-mode autolearn
[Device-GigabitEthernet1/0/1] port-security mac-address security 1-1-2 vlan 1